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????
Asked
Active
Viewed 106 times
2 Answers
4
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
-
So if I specificied and allow CORS in the server, that would suffice?...that could work because only my front-end is not allowed libraries, framework, etc – user998548 Apr 27 '19 at 23:46
-
@user998548 — yes – Quentin Apr 28 '19 at 07:04
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