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

Canary Command-R refresh shows 404 #3847

Closed
billnbell opened this issue Feb 20, 2018 · 4 comments
Closed

Canary Command-R refresh shows 404 #3847

billnbell opened this issue Feb 20, 2018 · 4 comments

Comments

@billnbell
Copy link

billnbell commented Feb 20, 2018

When clicking around it works fine. But when I press Command-R I get a 404. Why?

Is there something I need to setup with routes for SSR?

@billnbell
Copy link
Author

OK It has to do with

http://localhost:3000/my-community/

vs

http://localhost:3000/my-community

The http://localhost:3000/my-community works fine. How do I use that to make both work?

@billnbell
Copy link
Author

billnbell commented Feb 20, 2018

I did the following and it works:

    server.get('*', (req, res) => {
      // https://github.com/zeit/next.js/issues/1189
      const parsedUrl = parse(req.url, true)
      const { pathname, query } = parsedUrl

      if (pathname.length > 1 && pathname.slice(-1) === '/') {
        app.render(req, res, pathname.slice(0, -1), query)
      } else {
        handle(req, res, parsedUrl)
      }
    })

@obedparla
Copy link
Contributor

You can also use https://www.npmjs.com/package/connect-slashes if you're running express and it'll add the / at the end of your url for you. It solves a few bugs that your hand made code might not cover.

@timneutkens
Copy link
Member

It's something that has to be handled in userland, we basically enforce without / at the end.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 20, 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

3 participants