https://github.com/maccyber/next-custom-route-issue
Issue with custom route in now-dev
https://github.com/maccyber/next-custom-route-issue
Last synced: about 1 year ago
JSON representation
Issue with custom route in now-dev
- Host: GitHub
- URL: https://github.com/maccyber/next-custom-route-issue
- Owner: maccyber
- Created: 2019-04-27T15:19:14.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-27T15:20:11.000Z (about 7 years ago)
- Last Synced: 2025-01-24T19:34:34.479Z (over 1 year ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Describe bug
I'm having troubles with custom routes in next.js when running through `now dev`
I have defined a custom route in `now.json`
```json
"routes": [
{ "src": "/product/(?[^/]+)", "dest": "/product?name=$name" }
]
```
In `pages/product.js` `query.name` is passed from `getInitialProps`
```js
Product.getInitialProps = async ({ query }) => {
console.log(query.name || 'NOT FOUND') // returns "NOT FOUND" when accessing
// http://localhost:3000/product/test
return { name: query.name }
}
```
## To Reproduce
```
git clone https://github.com/maccyber/next-custom-route-issue
npm i
now dev -d
open http://localhost:3000/product/test
```