1

Doing a javascript only assignment, i was provided an ubuntu machine and would like to spin up a container with a nodejs Serving the HTML, css, javascript. Then i would like another container with the backend API...since this all happening in the same server or IP , Is that posible no cross Origin calls????

Daniel Cottone
  • 4,257
  • 24
  • 39
user998548
  • 175
  • 1
  • 10

2 Answers2

4

See the Same-origin policy:

Two URLs have the same origin if the protocol, port (if specified), and host are the same for both.

You can't have two different services listening on the same port, so even if your static content and API servers shared an IP address, they would have to run on different ports.

So you would either need to configure CORS for the API server, or configure your static content server to proxy requests to the API server.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
2

You would need to provide the correct CORS settings on your backend API; CORS does take into account port numbers. See this post for reference: CORS error on same domain?

Daniel Cottone
  • 4,257
  • 24
  • 39