# SearchUI issues with reverse proxy

**URL:** <https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [August 10, 2020, 11:18am UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390 "2020-08-10T11:18:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![turekg](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@turekg](https://discuss.elastic.co/u/turekg)\
**Post date:** [August 10, 2020, 11:18am UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390/1 "2020-08-10T11:18:34Z")

</div>

Hello,  
I am using App Search instance and a user interface based on elastic SearchUi example. I am reverse proxying the node.js app and the connections to the App Search API with Apache2.  
I cannot get this to work. I get the error message:  
`An unexpected error occurred: Cannot read property 'forEach' of undefined`  
I think this means that the search payload is not getting through but I am not 100% positive.

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [August 13, 2020, 12:29pm UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390/2 "2020-08-13T12:29:43Z")

</div>

Hey @turekg,

Are you seeing that error in your node.js app, or in the browser?

---

<div class="post-metadata">

**Author:** ![turekg](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@turekg](https://discuss.elastic.co/u/turekg)\
**Post date:** [August 13, 2020, 1:30pm UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390/3 "2020-08-13T13:30:04Z")

</div>

It shows in the browser, I am assuming it's getting passed back from the server.

---

<div class="post-metadata">

**Author:** ![turekg](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@turekg](https://discuss.elastic.co/u/turekg)\
**Post date:** [August 13, 2020, 1:32pm UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390/4 "2020-08-13T13:32:13Z")

</div>

The relevant bit of my proxy setup are:

```auto
   SSLProxyEngine On
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyVia Full

    Header always set Access-Control-Allow-Origin "*"
    Header always set Access-Control-Allow-Credentials false
    Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS"
    Header always set Access-Control-Allow-Headers "Accept, authorization, content-type, Host, Origin, x-swiftype-client, x-swiftype-client-version, x-swiftype-integration, x-swiftype-integration-version"

    # Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule ^(.*)$ $1 [R=200,L]

    ProxyPass / https://127.0.0.1:5000/
    ProxyPass /api/ https://127.0.0.1:3200/
    ProxyPassReverse / https://127.0.0.1:5000/
    ProxyPassReverse /api/ https://127.0.0.1:3200/

```

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [August 13, 2020, 2:25pm UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390/5 "2020-08-13T14:25:03Z")

</div>

Can you inspect the API request in the browser's Network panel and see what the payload looks like in the response?

---

<div class="post-metadata">

**Author:** ![turekg](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@turekg](https://discuss.elastic.co/u/turekg)\
**Post date:** [August 13, 2020, 2:42pm UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390/6 "2020-08-13T14:42:59Z")

</div>

The url is [https://fiji-search.mpi-cbg.de/](https://fiji-search.mpi-cbg.de/), and it is probably simpler if you inspect yourself.

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [August 13, 2020, 2:58pm UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390/7 "2020-08-13T14:58:02Z")

</div>

Your API request is returning a text/html webpage:

```auto
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><link rel="shortcut icon" href="/favicon.ico"/><title>Gitter Search</title><link href="/static/css/main.0ac613d8.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root" class="app-container"></div><script src="/static/js/main.2287eacc.js"></script></body></html>

```

---

<div class="post-metadata">

**Author:** ![turekg](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@turekg](https://discuss.elastic.co/u/turekg)\
**Post date:** [August 13, 2020, 3:15pm UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390/8 "2020-08-13T15:15:56Z")

</div>

OK, so where is it going wrong?

---

<div class="post-metadata">

**Author:** ![turekg](https://avatars.discourse-cdn.com/v4/letter/t/35a633/32.png) [@turekg](https://discuss.elastic.co/u/turekg)\
**Post date:** [August 14, 2020, 4:34pm UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390/9 "2020-08-14T16:34:39Z")

</div>

So the problem was in the order of the the proxy calls, argh!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 11, 2020, 4:34pm UTC](https://discuss.elastic.co/t/searchui-issues-with-reverse-proxy/244390/10 "2020-09-11T16:34:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
