gatsby: gatsby-plugin-remove-trailing-slashes not working when using `gatsby develop`
Description
gatsby-plugin-remove-trailing-slashes seems to work when running gatsby serve
but not when running gatsby develop
Steps to reproduce
I created a demo project from the CLI to demonstrate the behaviour.
https://github.com/itmayziii/gatsby-trailing-slahes-demo
Expected result
Gatsby plugins should work the same in develop as when building the project.
Actual result
gatsby develop
is not removing trailing slashes.
What happened.
Environment
System: OS: macOS 10.14.2 CPU: (8) x64 Intel® Core™ i7-7920HQ CPU @ 3.10GHz Shell: 3.2.57 - /bin/bash Binaries: Node: 10.15.0 - /usr/local/bin/node Yarn: 1.12.3 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm Browsers: Chrome: 71.0.3578.98 Firefox: 64.0.2 Safari: 12.0.2 npmPackages: gatsby: ^2.0.76 => 2.0.76 gatsby-image: ^2.0.20 => 2.0.25 gatsby-plugin-manifest: ^2.0.9 => 2.0.12 gatsby-plugin-offline: ^2.0.16 => 2.0.20 gatsby-plugin-react-helmet: ^3.0.2 => 3.0.5 gatsby-plugin-remove-trailing-slashes: ^2.0.6 => 2.0.6 gatsby-plugin-sharp: ^2.0.14 => 2.0.16 gatsby-source-filesystem: ^2.0.8 => 2.0.12 gatsby-transformer-sharp: ^2.1.8 => 2.1.9
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 22 (5 by maintainers)
Commits related to this issue
- fix: use trailing slashes More info here: https://github.com/gatsbyjs/gatsby/issues/11105 — committed to aleclarson/react-spring.io by aleclarson 4 years ago
- fix: use trailing slashes More info here: https://github.com/gatsbyjs/gatsby/issues/11105 — committed to aleclarson/react-spring.io by aleclarson 4 years ago
- [Site] Enable referer tracking with trailing slash URLs #85 == Analysis When faced with [the decision on trailing slashes in URLs][1], I settled for non-trailing as the default because they're short... — committed to nipafx/nipafx.dev by deleted user 4 years ago
Yes that’s exactly what I am talking about
not stale
Just in case anyone else comes across this issue, I’m solving the problem with a combination of Nginx configuration and the Gatsby remove trailing slashes plugin.
On the Nginx side I’m redirecting all trailing slash versions to the non trailing slash version This goes in my server block configuration
You need the Gatsby plugin also because even though the server is redirecting all traffic to the non trailing slash version, the Gatsby javascript seems to be adding the trailing slash to the URL bar. If you use the plugin it will stop doing that.
To clarify Behaviour without plugin https://www.example.com/test will give a 200 response but the javascript will change the url bar to be https://www.example.com/test/
It should be also noted I’m not using
gatsby serve
anywhere anymore. We are using docker with a Nginx container instead.bump, please reopen.
i’m seeing this with and w/o
gatsby-plugin-remove-trailing-slash
enabled.also, linking #19543 to this
Yeah let me give it a shot.
Expected When visiting http://www.domain.com/prices There should be no redirect to http://www.domain.com/prices/
Google has recommemded that a site should pick a convention of whether or not to use trailing slashes and stick to it https://webmasters.googleblog.com/2010/04/to-slash-or-not-to-slash.html
Our team has decided that the non trailing slash version of our site is our convention and this is replacing and existing site so it’s important that we follow the same existing url conventions.
Actual http://www.domain.com/prices does a 301 redirect to http://www.domain.com/prices/
It is expected that ‘gasby develop’ and ‘gatsby serve’ work the same way