Skip to content

[Bug]: Pages are not redirected to url with trailing slash #998

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

Closed
1 of 2 tasks
vpreponen opened this issue Dec 15, 2021 · 6 comments
Closed
1 of 2 tasks

[Bug]: Pages are not redirected to url with trailing slash #998

vpreponen opened this issue Dec 15, 2021 · 6 comments
Labels
type: bug code to address defects in shipped code v4 Issues related to the v4 Next.js runtime

Comments

@vpreponen
Copy link

Steps to reproduce

  1. Go to https://nifty-neumann-ecf646.netlify.app/arkisto
  2. Page is not redirected to https://nifty-neumann-ecf646.netlify.app/arkisto/

If I run yarn build && yarn export in local the files are created as arkisto/index.html. On Netlify it looks like they are created as arkisto.html.

A link to a reproduction repository

https://github.com/vpreponen/indyville/

Plugin version

4.0.0

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

No response

Your netlify.toml file

`netlify.toml`
[[redirects]]
  from = "/feed"
  to = "/feed.xml"
  status = 301
  force = true

[[redirects]]
  from = "/baari"
  to = "https://baari.indyville.fi/"
  status = 301
  force = true

[[redirects]]
  from = "/baari/*"
  to = "https://baari.indyville.fi/:splat"
  status = 301
  force = true

[[redirects]]
  from = "/retro"
  to = "https://retro.indyville.fi/"
  status = 301
  force = true

[[redirects]]
  from = "/retro/*"
  to = "https://retro.indyville.fi/:splat"
  status = 301
  force = true

[[redirects]]
  from = "/kuvat/*"
  to = "https://assets.indyville.fi/kuvat/:splat"
  status = 301
  force = true

[[redirects]]
  from = "/jw_flv/*"
  to = "https://assets.indyville.fi/video/:splat"
  status = 301
  force = true

[[redirects]]
  from = "/svg/*"
  to = "https://assets.indyville.fi/svg/:splat"
  status = 301
  force = true

[[redirects]]
  from = "/tiedostot/*"
  to = "https://assets.indyville.fi/tiedostot/:splat"
  status = 301
  force = true

[[redirects]]
  from = "/villen_muut_tiedostot/*"
  to = "https://vp.indyville.fi/files/:splat"
  status = 301
  force = true

[[redirects]]
  from = "/metsapuhuu/*"
  to = "https://vp.indyville.fi/metsapuhuu/:splat"
  status = 301
  force = true

Relevant log output (or link to your logs)

Build logs

https://app.netlify.com/sites/nifty-neumann-ecf646/deploys/61b9c66dc562b20008e09ff6

@vpreponen vpreponen added the type: bug code to address defects in shipped code label Dec 15, 2021
@tiffafoo
Copy link

Hello! Thanks for raising up this issue.

Trailing slash is not enabled by default by Next, so you'll have to enable it in the config. Instructions on how to do so can be found in the Next Docs.

I also noticed you have two next plugins installed, you can remove netlify-plugin-cache-nextjs which is an older version. One other thing, we do not do any building with next export on the Netlify side, which exports your Next.js application to static HTML.

Let me know if that works for you!

@vpreponen
Copy link
Author

Trailing slash is enabled in the config and this works for urls that don't match to static files.

I previously tested removing the cache plugin but this throws a warning during deploy and doesn't fix the redirects.

warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache

@tiffafoo
Copy link

tiffafoo commented Dec 15, 2021

Ahh, got it, thanks for the extra info. Sadly there doesn't seem to be a great workaround to this yet. Changing your site to not use the CDN via an environment variable (SERVE_STATIC_FILES_FROM_ORIGIN) to make it serve from the origin instead should resolve this for you, but that is at the cost of some performance.

@vpreponen
Copy link
Author

All right, thanks for the help. I'll have to change my relative urls to root relative then.

@tiffafoo tiffafoo added wontfix This will not be worked on and removed status: awaiting user response labels Dec 16, 2021
@MarcL
Copy link
Contributor

MarcL commented Jul 5, 2022

#1448

@MarcL MarcL removed the wontfix This will not be worked on label Jul 4, 2023
@MarcL MarcL added v4 Issues related to the v4 Next.js runtime and removed Ecosystem: Frameworks labels Mar 13, 2024
@MarcL
Copy link
Contributor

MarcL commented Apr 19, 2024

The team at Netlify have now released the new v5 Next.js runtime which has support for both pages and app router, on-demand and time-based revalidation, automatic fine-grained cache control, and automatic image optimization using Netlify's image CDN. This should also fix this issue.

You can find the documentation and additional information here: Next.js on Netlify

The v4 runtime is now in the maintenance support phase with no new features being added. Occasional bug fixes and security patches will be applied when needed.

Thanks!

@MarcL MarcL closed this as completed Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code v4 Issues related to the v4 Next.js runtime
Projects
None yet
Development

No branches or pull requests

3 participants