I’m attempting to build a Gastby site on Netlify that has the pathPrefix setting configured in gatsby-config.js. I’m trying to serve the site under a /news subdirectory.
When I build locally, taking care to use the --prefix-paths switch, everything works correctly and the site appears as localhost:8000/news.
I’ve added the --prefix-paths settings to the npm run build command in netlify.toml, as well as on the UI in my Netlify panel, but still Netlify doesn’t build the gatsby site to appear under the /news subdirectory.
Am I missing another configuration of some sort? I can see in Netlify’s build log that the --prefix-paths switch is being included in the npm run build command, but the /news subdirectory does not appear on the live Netlify site.
However, related problem is that now /admin paths (for Netlify CMS) are also prefixed, breaking things like redirects after login.
@futuregerald Do you know if there’s a way to prevent prefix-paths from corrupting the /admin paths?
The use case is that the gatsby site runs behind another site via a nginx reverse proxy (on a path like our-real-site.com/news), but we want admins to hit the Netlify site directly like my-strange-automatic-name.netlify.com/admin and have invite and login workflows work normally without getting broken due to prefix paths setting.
You can’t access admin from the upstream site like (main site url)/news/admin, because you’ll get a “Failed to load settings from /.netlify/identity” error…meaning admins will have to access the Netlify site directly, meaning the prefix-paths shouldn’t apply to /admin
Hmm. Not sure if there’s a way to exclude particular paths from getting the prefix added to it. That’s really a feature specific to Gatsby and you may be able to find more information about that on their site.
One thing you could try is adding the cms manually based on the docs rather than using a Gatsby plugin. This will make the /admin path ‘live’ outside of your Gatsby site and will not have the prefix added. Maybe that will work for you.