erikras / react-redux-universal-hot-example

A starter boilerplate for a universal webapp using express, react, redux, webpack, and react-transform
MIT License
12.01k stars 2.5k forks source link

Add global variables for sub-folder routing #1236

Open sauravskumar opened 8 years ago

sauravskumar commented 8 years ago

I am working on multiple applications which will be hosted under the same domain name.

for eg. http://example.com/hotels (standalone react app), http://example.com/coupons (another standalone react app) etc.

In development we used url structure to route to url http://localhost:3000/* and now in production the urls to redirect to http://example.com/* which thus breaks the app since in production it should be like http://example.com/hotels/*

Are there any changes i can make to this starter kit such that all urls get a placeholder value added to the them.... or will i have to individually change all urls from /* to /hotels(app-name)

VSuryaBhargava commented 7 years ago

Maybe you can change the below at line 63 of src/server.js

app.use((req, res) => {
  if (__DEVELOPMENT__) {
    // Do not cache webpack stats: the script file would change since
    // hot module replacement is enabled in the development env
    webpackIsomorphicTools.refresh();
  }

to

let path = '/hotels';
if (__DEVELOPMENT__) {
 path = '*';
}
app.use( path , (req, res) => {
  if (__DEVELOPMENT__) {
    // Do not cache webpack stats: the script file would change since
    // hot module replacement is enabled in the development env
    webpackIsomorphicTools.refresh();
  }

You would also need to change the ApiClient.js file and the proxy url in server.js file