0

I have an application built using Express, Mongoose, React and Node. My application is hosted on a location which looks like the following: https://example.com/app_name which means that app_name is the base path for all of the static assets.

I'm using Webpack and setting publicPath to https://example.com/app_name. I can reach my static assets just fine, but when I attempt to do a call to my back-end, my requests are being routed to https://example.com/api/... instead of https://example.com/app_name/api/....

Is there a way to prefix my endpoint calls so that they use https://example.com/app_name/api/... instead of https://example.com/api/...through webpack or any other means?

mikeyGlitz
  • 423
  • 3
  • 13
  • "my requests are being routed to https://example.com/api/... instead of https://example.com/api/..." Possible typo? – T Porter Dec 07 '17 at 13:20
  • I don't see a problem with the way your paths are defined, it would be silly to have your api served from a static assets directory. Now when you say you "can't reach backend" what do you mean? You might have CORS-related issues which need to be specifically dealt with. Could you post your server.js source? – Thomas Hennes Dec 07 '17 at 13:20
  • Or do you mean `/app_name` is the root location of your entire project? Your question is ambiguous. – Thomas Hennes Dec 07 '17 at 13:22
  • `app_name` is not a public directory. The application sits behind a proxy that passes traffic from `https://example.com/app_name` to the server where my application is running. – mikeyGlitz Dec 07 '17 at 14:17

0 Answers0