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

Latest version of Next.js is breaking this #3

Closed
justincy opened this issue Aug 13, 2020 · 9 comments · Fixed by #5
Closed

Latest version of Next.js is breaking this #3

justincy opened this issue Aug 13, 2020 · 9 comments · Fixed by #5

Comments

@justincy
Copy link
Owner

I don't know what has changed in the last two months since I've been in this repo, but something is preventing our little hacks from working. It's somehow able to see past our rewrites and is returning a 308 redirect. I should be able to search their codebase for 308 and figure out what's going on.

@justincy
Copy link
Owner Author

v9.5.0 introduced the change. It was probably the trailing slash API changes.

@justincy
Copy link
Owner Author

When I ask for the home page / it's returning a redirect, presumably because it knows that page doesn't exist (all pages are inside the dynamic [locale] dir). But we have a rewrite middleware in place so that it thinks a different page is being requested. So that rewrite must not be working anymore which means they must've changed the logic for how they figure out which URL is being requested.

@justincy
Copy link
Owner Author

@justincy
Copy link
Owner Author

How would Next.js know to forward to /en?

@justincy
Copy link
Owner Author

Here's what I'm seeing:

logger: GET nexttest.com/
rewrite: GET nexttest.com/en/
logger: GET nexttest.com/en
rewrite: GET nexttest.com/en/en

@justincy
Copy link
Owner Author

Removing the trailing slash from the / rewrite (so that we get /en instead of /en/) seemed to make a difference. I accomplished that by modifying this line:

req.url = `/${locale}${req.url}`;

To be:

    req.url = `/${locale}${req.url}`.replace(/\/$/, '');

That avoids the redirect but for some reason the page doesn't render. The server sends the HTML but it doesn't hydrate and render. 😮

@justincy
Copy link
Owner Author

The body has the style display: none and the links trigger reloads (instead of a SPA navigation) so it's clear that Next isn't running and hydrating the UI.

@justincy
Copy link
Owner Author

I bet there's some other data on the front-end that checks URLs and known locations to see if it ought to run. We trim the locale so the path won't match. We try to fix that by modifying the path in the NEXT_DATA but apparently that's not good enough anymore.

Should we keep trying or give up on hacking?

@justincy
Copy link
Owner Author

We're going to leave this for now and try a different strategy that doesn't use the dynamic [locale] directory.

This was referenced Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant