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

netlify adapter docs: add warning on redirects file placement #1596

Closed
wants to merge 2 commits into from

Conversation

swyxio
Copy link
Contributor

@swyxio swyxio commented May 30, 2021

Before submitting the PR, please make sure you do the following

addresses #1586 to hopefully save others from the same confusion

@benmccann benmccann added documentation Improvements or additions to documentation pkg:adapter-netlify labels May 30, 2021
@benmccann
Copy link
Member

This feels quite wrong to me. _redirects isn't a static asset. There are three different directories that get copied into the publish directory. We'd just be relying on the fact that static assets end up in the publish directory, but it's quite an unintuitive place to have to put the file.

I'd rather put it at the root of the project. In neither case would we be putting it directly in the publish directory, but rather relying on the adapter to copy it to the right place. It's just a question of where would you most expect it to live. Living next to netlify.toml makes more sense than living next to your image files, etc. in my opinion

@swyxio
Copy link
Contributor Author

swyxio commented May 31, 2021

i see. so perhaps @roschaefer should reopen #1586 ?

@kvn-shn
Copy link
Contributor

kvn-shn commented May 31, 2021

At least to me it feels quite intuitive putting it into static/ (e.g. next to robots.txt) because it's more like an oldschool .htaccess file that belongs in the "public_html" of the server... After all it is, in the context of Svelte, a static asset that Svelte can't and won't do anything with.

So in my opinion this PR would do the trick.

@benmccann
Copy link
Member

I went ahead and merged #1586. It shouldn't stop you from putting it in static/ if you'd like, but I think supporting it in the root directory next to netlify.toml makes a lot of sense

@benmccann benmccann closed this Jun 1, 2021
@swyxio swyxio deleted the patch-1 branch June 1, 2021 17:01
> [Netlify docs here](https://docs.netlify.com/routing/redirects/)

Netlify supports declarative redirects via a `_redirects` file. Place it in the `static/` folder, NOT in your project root next to `netlify.toml`.

During compilation a required "catch all" redirect rule is automatically appended to your `_redirects` file. (If it doesn't exist yet, it will be created.) That means:

- `[[redirects]]` in `netlify.toml` will never match as `_redirects` has a [higher priority](https://docs.netlify.com/routing/redirects/#rule-processing-order). So always put your rules in the [`_redirects` file](https://docs.netlify.com/routing/redirects/#syntax-for-the-redirects-file).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just fyi - i think this is inaccurate - the doc actually says "Rules in the _redirects file are always processed first, followed by rules in the Netlify configuration file."

in other words you CAN put stuff in netlify.toml, AND in _redirects, its just that the latter overrides the former in cases of conflict.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's true when you consider the catch-all route that gets added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation pkg:adapter-netlify
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants