Make file-system based routes optional for custom servers#914
Conversation
There was a problem hiding this comment.
Think we can remove the !== false and add the default here https://github.com/zeit/next.js/blob/master/server/config.js#L6
|
Some people might even be interested in customizing the name of the directory, for example:
i wonder if |
|
@rauchg that's interesting. |
|
I really like |
|
@rauchg I dig the direction on using this to also customize @arunoda Hm, perhaps I'm misunderstanding but it seems like the custom server code needs to implement |
|
Since we do |
|
I think the As @arunoda mentioned, you don't need the flag if you define customs routes over file-system based ones, though it would be inconvenient. Another way is to set the option as an argument of handle(req, res, { fileSystemRoutes: false }) |
Ah, of course, that makes sense @nkzawa. I'm less sure if we want to add a secondary configuration into For now though, I'll proceed with adding the two options into next.config: (Using the key |
|
Let's not include |
|
Sounds good @nkzawa, I'll split it into a separate PR and move that part of the discussion over there 👍 |
9da8170 to
fa07f9d
Compare
|
@arunoda can you check this one and merge if you want to take it 👍 |
|
Okay. I'm good with this. |
|
Should documentation be added? |
|
@sedubois yeah! We can add it here in the options: https://github.com/zeit/next.js#custom-server-and-routing |
2 changes: `passHref` - just added a cautionary note on the importance of `passHref`. We had a few days of no-href links on our site b/c we used a custom component instead of a raw `<a>` tag, and Google bot wasn't crawling our links (confirmed in Google cache). Hurt our SEO a bit, so I thought it was worth noting. `useFileSystemPublicRoutes` - this is mentioned in vercel#914 , but it doesn't appear any doc was actually added. We use `next-routes`, and we were serving all the files in `/pages/` in addition to their route patterns (ie duplicate content), which can be a pain w/ SEO and duplicate content.
2 changes: `passHref` - just added a cautionary note on the importance of `passHref`. We had a few days of no-href links on our site b/c we used a custom component instead of a raw `<a>` tag, and Google bot wasn't crawling our links (confirmed in Google cache). Hurt our SEO a bit, so I thought it was worth noting. `useFileSystemPublicRoutes` - this is mentioned in #914 , but it doesn't appear any doc was actually added. We use `next-routes`, and we were serving all the files in `/pages/` in addition to their route patterns (ie duplicate content), which can be a pain w/ SEO and duplicate content.
2 changes: `passHref` - just added a cautionary note on the importance of `passHref`. We had a few days of no-href links on our site b/c we used a custom component instead of a raw `<a>` tag, and Google bot wasn't crawling our links (confirmed in Google cache). Hurt our SEO a bit, so I thought it was worth noting. `useFileSystemPublicRoutes` - this is mentioned in vercel#914 , but it doesn't appear any doc was actually added. We use `next-routes`, and we were serving all the files in `/pages/` in addition to their route patterns (ie duplicate content), which can be a pain w/ SEO and duplicate content.
* Add .jsx extension * examples: add create-next-app (#3377) * examples: add create-next-app * fix with-typescript readme * Upgrading with-flow example to the latest flow-bin ver. 0.59.0 (#3337) For upgrading I used flow-upgrade module by https://yarnpkg.com/en/package/flow-upgrade * doc'd fs-routing option & added note on `passHref` (#3384) 2 changes: `passHref` - just added a cautionary note on the importance of `passHref`. We had a few days of no-href links on our site b/c we used a custom component instead of a raw `<a>` tag, and Google bot wasn't crawling our links (confirmed in Google cache). Hurt our SEO a bit, so I thought it was worth noting. `useFileSystemPublicRoutes` - this is mentioned in #914 , but it doesn't appear any doc was actually added. We use `next-routes`, and we were serving all the files in `/pages/` in addition to their route patterns (ie duplicate content), which can be a pain w/ SEO and duplicate content. * fix typo in readme.md (#3385) * Upgrade styled-jsx to v2.2.1 (#3358) * Pulled encoding to top of head (#3214) * Remove next.d.ts to use @types/next (#3297) * Add with-mobx-state-tree example (#3179) * Adapt with-mobx example for with-mobx-state-tree * Remove unnecessary lastUpdate parameter to show off snapshot * update readme * make other.js more closely mimic index.js * Upgrade styled-jsx to v2.2.1 Includes some bug fixes. * Fix linting * Make sure import that doesn’t end in .jsx works * Move tests * Show error when .js and .jsx both exist * Remove .jsx when importing from ‘path.jsx’ * Fixes * Get .jsx resolver back * Revert "Get .jsx resolver back" This reverts commit 6f76712. * Revert "Revert "Get .jsx resolver back"" This reverts commit 69e592e. * Add remove .jsx to preset * Remove jsx resolver * Revert "Remove jsx resolver" This reverts commit 5e3ef1a. * Revert "Revert "Remove jsx resolver"" This reverts commit 8248e50. * Revert "Revert "Revert "Remove jsx resolver""" This reverts commit 2a6d418. * Make 1 component not use .jsx
Related to #913, and making a custom routing setup more generally:
If you're using a custom server per the README and examples, you may not want to keep the file-system based routes. This commit simply puts that behind a configuration setting, so that you could turn those routes off by the following
config.next.js:If this is an acceptable solution I can expand the tests to cover it — let me know if that's worth doing. Thanks again for all the hard work!