Reputation: 1157
I have a GatsbyJS static site built with --prefix-paths
. The pathPrefix
is set to /environment/test
in gatsby-config.js
. It is deployed to a docker swarm running Traefik.
Adding the following label to the service makes everything run ok:
traefik.frontend.rule=PathPrefixStrip:/environment/test
I can then browse to /environment/test
and click around in my GatsbyJs site.
However I find it strange since the backend is build with the path prefix.
Adding the following label does not work:
traefik.frontend.rule=PathPrefix:/environment/test
Shouldn't it work with PathPrefix
instead of PathPrefixStrip
?
Upvotes: 4
Views: 3342
Reputation: 862
The pathPrefix
configuration in GatsbyJS means that every link of your website will be prepended with /environment/test
(see documentation), but this does not mean that on the container running the website, the page is actually hosted on this path.
In your situation, it seems it is not the case.
This means that when connecting via Traefik with the PathPrefixStrip
, when in your browser you click on a link:
/environment/test/page
/page
/
so it answers with the pageWhen connecting via Traefik with the PathPrefix
:
/environment/test/page
/environment/test/page
/
so it doesn't find the page.Hence, you are confusing the pathPrefix
setting of a website with the path from which the very same website is served.
The alternative to the current situation would thus be to serve the website under /environment/test/
and use PathPrefix
with traefik.
Upvotes: 17