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

Router.push add unnecessary "/" suffix on end of url in export code #4411

Closed
mydearxym opened this issue May 17, 2018 · 3 comments
Closed

Router.push add unnecessary "/" suffix on end of url in export code #4411

mydearxym opened this issue May 17, 2018 · 3 comments

Comments

@mydearxym
Copy link

mydearxym commented May 17, 2018

hey there ~

when i call Router.push in dev mode, every thing works fine, and browser url looks as expected

Router.push('/', `/racket/posts`)
http://192.168.31.162:8000/racket/posts

but when i compile the site in static files use next export, the Router.push automatic add a "/" suffix in the end of the url :

http://192.168.31.162:8000/racket/posts/

page/index.js

export default class Index extends React.Component {
  static async getInitialProps({ req, pathname, asPath }) {
    console.log('getInitialProps asPath ---> ', asPath)  // ==> /racket/posts/
   }
   .....
}

get 303 in browser

image

related: #1189 #619 #3876

System information

  • OS: macOS
  • Browser: chrome
  • Version of Next.js: 6.0.3

Additional context
i am using custom server route

@mydearxym mydearxym changed the title Router.push as add unnecessary "/" suffix on url in production code Router.push add unnecessary "/" suffix on url in production mode May 17, 2018
@mydearxym mydearxym changed the title Router.push add unnecessary "/" suffix on url in production mode Router.push add unnecessary "/" suffix on end of url in export code May 17, 2018
@NathanielHill
Copy link
Contributor

This isn't the router. When the site is exported a page like pages/about.js gets converted to about/index.html to avoid having the .html suffix in the location bar. There are several issues about this, including a PR #3283. Hopefully this is implemented, it's my only problem with using static exports.

@NathanielHill
Copy link
Contributor

This is fixed 🎉
https://zeit.co/blog/new-static-deployments

@mydearxym
Copy link
Author

@NathanielHill awesome !

@lock lock bot locked as resolved and limited conversation to collaborators Jun 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants