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

double slash followed by any char after domain causes infinite page reloading #9692

Open
dimanche-matin opened this issue Jul 2, 2024 · 5 comments · Fixed by #9695
Open

Comments

@dimanche-matin
Copy link

dimanche-matin commented Jul 2, 2024

Reproduction

Add double slash followed by any char after domain (e.g. https://example.com//foo), then Enter.

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M1
    Memory: 59.33 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.7.1 - /opt/homebrew/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.5.0 - /opt/homebrew/bin/npm
  Browsers:
    Brave Browser: 125.1.66.115
    Chrome: 126.0.6478.127
    Edge: 126.0.2592.81
    Safari: 17.5
  npmPackages:
    @remix-run/dev: ^2.9.2 => 2.9.2 
    @remix-run/node: ^2.9.2 => 2.9.2 
    @remix-run/react: ^2.9.2 => 2.9.2 
    @remix-run/serve: ^2.9.2 => 2.9.2 
    vite: ^5.1.0 => 5.2.13

Used Package Manager

npm

Expected Behavior

404 Not Found

Actual Behavior

Infinite reloading with this console error log:
"Initial URL (/) does not match URL at time of hydration (//foo), reloading page..."

Some web sites listed on https://remix.run/showcase are affected.

@brophdawg11
Copy link
Contributor

This should be resolved via #9695 and available in the next release 👍

@brophdawg11 brophdawg11 added the awaiting release This issue has been fixed and will be released soon label Jul 24, 2024
Copy link
Contributor

🤖 Hello there,

We just published version 2.11.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@dimanche-matin
Copy link
Author

Bug persists on 2.11.0-pre.0.

When navigating on //foo path :

On 2.9.2 :

On client :
remix_2 9 2_p1_client_crop-min

On server :
Empty

On 2.11.0-pre.0 :

On client :
remix_2 11 0-pre 0_p1_client_crop-min

On server :
Empty

When navigating on /foo//bar path :

On 2.9.2 :

404 Not Found

On 2.11.0-pre.0 :

On client :
remix_2 11 0-pre 0_p2-3_client_crop-min

On server :
remix_2 11 0-pre 0_p2_server_crop-min

When navigating on //foo//bar path :

On 2.9.2 :

On client :
remix_2 9 2_p3_client_crop-min

On server :
remix_2 9 2_p3_server_crop-min

On 2.11.0-pre.0 :

On client :
remix_2 11 0-pre 0_p2-3_client_crop-min

On server :
remix_2 11 0-pre 0_p3_server_crop-min

@brophdawg11
Copy link
Contributor

ah ok so this instance wasn't just from a url mismatch after all. I'll reopen and we can consider trying to detect and resolve this but I think I would recommend tackling this in user land for now and just redirecting prior to handling off the double-slash url to the Remix handler. Yolu could put this right before the remix handler in your express server:

  app.all("*", (req, res, next) => {
    if (req.path.includes('//')) {
      res.redirect(req.path.replace(/\/+/g, '/'));
    } else {
      next();
    }
  });

@brophdawg11 brophdawg11 reopened this Jul 31, 2024
@brophdawg11 brophdawg11 removed the awaiting release This issue has been fixed and will be released soon label Jul 31, 2024
Copy link
Contributor

github-actions bot commented Aug 1, 2024

🤖 Hello there,

We just published version 2.11.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants