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

Custom Netlify Redirects Overwritten #158

Closed
juanpprieto opened this issue Mar 17, 2021 · 4 comments
Closed

Custom Netlify Redirects Overwritten #158

juanpprieto opened this issue Mar 17, 2021 · 4 comments

Comments

@juanpprieto
Copy link

juanpprieto commented Mar 17, 2021

Describe the bug
netlify-plugin-nextjs seems to overwrite custom _redirects file rules

To Reproduce
Steps to reproduce the behavior:

  1. Add custom rules to: public/_redirects
  2. netlify build
  3. Check out_publish/_redirects includes only # Next-on-Netlify Redirects....

Expected behavior
I would expect to see the custom redirect rules merged in at the very top of the out_publish/_redirects file

Versions

  • Next.js: "next": "^10.0.3"
  • plugin (if installed at fixed version): "@netlify/plugin-nextjs": "^3.0.0"

If you're using the CLI to build

  • OS: [e.g. macOS, Windows]: Mac
  • netlify/cli version: netlify-cli@3.10.5

If you're using file-based installation

  • netlify.toml:
# netlify.toml

[build]
  # base = "storefront/"
  command   = "yarn build"
  publish   = "storefront/out_publish"
  functions = "storefront/out_functions"

[dev]
  functions = "out_functions"
  publish   = "out_publish"
  framework = "#static"

# needs to be included before
[[plugins]]
  package = "/plugins/my-custom-plugin"
   [plugins.inputs]
    build_dir_path = "storefront"
    build_dir = ".next"
    json_dir = "public/json"

[[plugins]]
  package = "@netlify/plugin-nextjs"

Custom _redirects

#### PRODUCTS REDIRECTS START ####
/json/products/navy-feel-good-short-sleeve-shirt /json/products/navy-feel-good-short-sleeve-shirt___2021-03-16T22:24:05Z.json 200
.......
#### PRODUCTS REDIRECTS END ####
@juanpprieto juanpprieto changed the title Custom Netlify Redirects Custom Netlify Redirects Overwritten Mar 17, 2021
@lindsaylevine
Copy link

@juanpprieto hey! the plugin doesn't override - it reads your custom redirects from the root of your project. if you put your _redirects file at the root of your project, instead of public/_redirects, it should work. lmk!

@juanpprieto
Copy link
Author

@lindsaylevine amazing that worked! thanks

I had a feeling it was simply ignoring it (from being in the wrong path) rather than overwriting it.

Feel free to close and thanks once again for the quick response.

@lindsaylevine
Copy link

@juanpprieto haha yeah of course!!! happy to help!!

@zomars
Copy link

zomars commented May 21, 2021

I'm glad I've found your comment @lindsaylevine ! I think it can be confusing for someone following the docs like me:

Save a plain text file called _redirects to the publish directory of your site. You can find _redirects file syntax details below.

Maybe we can add a note there that it may vary if you're using a framework like Next.js since we're not using the "publish directory" in here.

serhalp pushed a commit that referenced this issue Apr 5, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
* feat: remove x-nextjs-cache header and add Cache-Status instead

* chore: rename cache name from 'Next Cache' to 'Next.js'

* test: adjust test after removing x-nextjs-cache header and adding cache-status

* test: cache-status can have multiple values, adjust assertions for that

* test: e2e quirks worked out

---------

Co-authored-by: Rob Stanford <me@robstanford.com>
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

3 participants