Changing PUBLIC_URL is not working

Hello, I added the env the PUBLIC_URL in netlify and set it to .app, I also modified my react app to have the proper basename as specified by process.env.PUBLIC_URL and modified the routes accordingly.

The app now has the correct URLs so for example it has /app/static/js instead of /static/js in index.html but the files are only actually in /static/js … /app/static/js it will only serve index.html, how do I build this properly so everything is served from /app/ and not /.

@mike_k You haven’t said what you’re building with.

Are you able to provide a link to your repository so others can check how the build itself is configured?

If you want your output to actually live at /app/ on Netlify, then the key to doing that would be to get it to build into that folder, with the correct paths in the files, and to then set the Deploy directory to be the folder above it.

So if /static/ is the folder your files are normally output into, you want to configure your build, (through the placement of your files, folders & its configuration), to build into /static/app/ and then you want to tell Netlify to deploy /static.

Hello Nathan, I can’t share a the repository since its a clients. It’s a react app and we are using react-create-app. How would I go about telling Netlify to deploy /static and any further pointers you can give for configuring the react app would be highly appreciated.

I should also add, the reason I am doing this is because the domain is being reverse proxied, so is proxied to a completely different platform and proxies the app on netlify.

@mike_k I’ve helped plenty of people configure their react apps to work on Netlify, but I don’t use react myself so I don’t keep any info on “how it operates” fresh in my mind to be able to instruct you blind.

You should just run your build locally, see what it outputs, and then read the details in my original message and see if they align with what you’re producing.

If they don’t, adjust your build so they do.

I completely understand not being able to provide the repository publicly, however I only provide assistance publicly in the hopes that it will help the developers that use the search tool and encounter the same thread.

I juggle a lot of work so can’t entertain spending too long trying to debug or instruct blindly, and helping people privately (where they supply private repo access etc), isn’t something that I do as it’s ultimately just free consultancy work (as I’m not a Netlify employee).

1 Like