[SOLVED] Ember data sending requests from my computer browser instead of its own machine?

Hello! I have the following scenario:

  1. I generated an ember build with environment=prod, and generated a docker Nginx image that serves this generated build. It uses backend-host as the API host (defined in environment.js)
  2. I deployed the docker image in a Kubernetes cluster. In the same pod I have the backend-hostcontainer working just fine.
  3. I exposed the Nginx using a load balancer on Kubernetes. You might access it through http://191.239.244.167:4200/
  4. EmberJS seems not able to access backend-host(you can check it by seeing the Networks tab)
  5. If I run the backend on my local computer and add a /etc/hosts entry to map backend-host to this local server from my computer, the app correctly communicates with my local backend. As if only the browser context is being used

So, my question is: there is any way to tell Ember to use its machine context instead of my browser? Thank you!

Hi Dylan,

Ember is supposed to run in the browser, including Ember Data. All Nginx does is serve the files containing your Ember application to the browser. It is not capable of running JavaScript.

What you need to do is make your back-end node accessible outside your K8s cluster, as you did for your Nginx node. There are other options, such as setting up Nginx to proxy to the back-end node, but that amounts to the same thing. If you really have a need to run some JavaScript code inside the cluster, you will need a Node.js server, not Nginx.

1 Like

Gotcha, thank you!

That’s funny: I’ve been using apps built with Ember (Twitch, Discourse, etc) and I always thought their backend was being accessed by the machine serving the Ember app build instead of my own personal browser. But, after your comment, being accessed by the browser makes way more sense, especially thinking in sense of CDN servers. Thank you and have a great year! :slight_smile: