Deploying Webpack on a subpath

Explanation of my Doubt

I got an app running and holded on a Docker Container usign:

  • Webpack
  • React Router 4
  • Express.js
  • Apollo Data

My app works perfect under a Root Folder www.mycoolurl.com/. But i got other app running on my root so i created www.mycoolrul.com/coolsubpath

Express

app.use(express.static(__dirname + "/dist"));

app.get("/*", function(req, res) {
	res.sendFile(__dirname + "/dist/index.html");
});

Nginx Config

    upstream coolapp{
        server       1.1.1.1:8000;
    }
    
    
    
    location /coolsubpath {
        # Upstream
        proxy_pass         http://coolapp/;
        proxy_redirect     off;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;
        client_max_body_size 3M;
    }

My first experience with this was awful … every request tried to mount my App, Vendor and Manifest (webpack stuff, that only need to be mounted on root). So i end up doing this:

Webpack Config

    output: {
    	filename: "[name].[chunkhash].js",
    	path: resolve(__dirname, "../dist"),
    	chunkFilename: "[chunkhash].js",
    	publicPath: "/"
    },

Now only the root will load the assets but… when i go to www.mycoolrul.com/coolsubpath only my index.html is found and …Assets Loading

The assets are looking for my ex. www.mycoolurl.com/app.761c16f76fcba6601577.js/ instead of www.mycoolrul.com/coolsubpath/app.761c16f76fcba6601577.js/.

What i Expect

I tested adding React Router 4 subpath… and my Express.js the subpath name to the .get and .use methods. Yes, it works. But now i want my subpath to be instead of coolsubpath like ex. mynewsupercoolsubpath. I have to rebuild and deploy the app again ?.

What i tried…

I tried rewriting the request url but had no luck, i know the code is wrong… but i dont know how to do it

    if ($http_referer ~* ^www.mycoolrul.com/coolsubpath ) {
       set $request_url /coolsubpath/$1;
    }

Is this a Meteor question (it doesn’t seem to be), or an Apollo question (again, it doesn’t seem to be)?

@robfallows its an ApolloServer/ApollClient deploy… so maybe why not.

Maybe apollo would be a better category, since deploymentis more for Meteor deployments?

Im Sorry i didnt know that. I edited the post section. Thanks.

My temporal solution is to add the /subpath to all my stuff… like RR4… Express… Webpack… maybe this is the way ? it doesnt feel good :unamused: