Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omitting files from trailingSlash redirect behaviour #115

Closed
danielstocks opened this issue Feb 3, 2020 · 1 comment
Closed

Omitting files from trailingSlash redirect behaviour #115

danielstocks opened this issue Feb 3, 2020 · 1 comment

Comments

@danielstocks
Copy link

danielstocks commented Feb 3, 2020

Hi,

I'm using the trailingSlash: true option to redirect all my pages from /page to /page/. However this has the unintended consequence of also redirecting /image.jpeg to /image.jpeg/.

After having a look through the ZEIT now spectrum community, someone suggested:

routes [{ 
    "src": "/(((?!\\?|#|\\.|_next).)*((?!\\?|/|#|\\.).))", 
    "status": 301,
    "headers": { "Location": "/$1/" }
 }]

Eg. redirect all paths to trailing slash, unless it's a file (or the _next) folder.

Am I missing something here or isn't this the intended behaviour of trailingSlash?

Thanks in advance

@danielstocks danielstocks changed the title Omitting files from trailingSlash Omitting files from trailingSlash redirect behaviour Feb 3, 2020
@danielstocks
Copy link
Author

Ok sorry, I'm closing this issue because it seems the problem is with now dev and not serve.

After conducting an experiment on localhost with the trailingSlash configured both in now.json and serve.json I can conclude the following:

running now dev yields:

Screenshot 2020-02-04 at 07 59 59

where as serve results in:

Screenshot 2020-02-04 at 08 00 22

I would say the expected behaviour here is what serve does. I've done a reproducible test here:

https://github.com/danielstocks/trailing-slash-experiments

I think in general my confusion comes from me thinking zeit now uses serve under the hood, maybe I'm mistaken?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant