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

Adding // to the end of the root route throws an Internal Server Error #4422

Closed
krall12 opened this issue Oct 26, 2022 · 5 comments · Fixed by #5336
Closed

Adding // to the end of the root route throws an Internal Server Error #4422

krall12 opened this issue Oct 26, 2022 · 5 comments · Fixed by #5336
Labels
bug Something isn't working

Comments

@krall12
Copy link

krall12 commented Oct 26, 2022

What version of Remix are you using?

1.7.3

Steps to Reproduce

Spin up a new remix project from scratch. Just the basics. Remix Server. JavaScript.

Start the dev server and visit the browser at localhost:3000//.

Also, for fun check out https://remix.run//

Expected Behavior

I would expect this to not error. Ideally it would redirect back to the root route.

Actual Behavior

On production: An Internal Server Error is thrown that doesn't get caught by Error Boundaries.

On development: An Invalid URL error is thrown that also doesn't get caught by Error Boundaries.

TypeError: Invalid URL
    at new NodeError (node:internal/errors:372:5)
    at URL.onParseError (node:internal/url:553:9)
    at new URL (node:internal/url:629:5)
    at createRemixRequest (/Users/bkrall/content/remix-bug-server-error-on-route/node_modules/@remix-run/express/dist/server.js:67:13)
    at /Users/bkrall/content/remix-bug-server-error-on-route/node_modules/@remix-run/express/dist/server.js:37:21
    at /Users/bkrall/content/remix-bug-server-error-on-route/node_modules/@remix-run/serve/dist/index.js:48:7
    at Layer.handle [as handle_request] (/Users/bkrall/content/remix-bug-server-error-on-route/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/bkrall/content/remix-bug-server-error-on-route/node_modules/express/lib/router/route.js:144:13)
    at next (/Users/bkrall/content/remix-bug-server-error-on-route/node_modules/express/lib/router/route.js:140:7)
    at next (/Users/bkrall/content/remix-bug-server-error-on-route/node_modules/express/lib/router/route.js:140:7)
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2023

🤖 Hello there,

We just published version v0.0.0-nightly-7f3c92b-20230202 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!

@brophdawg11
Copy link
Contributor

This is fixed in Remix 1.13.0 - we aren't doing any redirecting but instead are ensuring our adapters can correctly generate a URL with these trailing slashes. It would still be up to the app to detect and redirect in a loader (or eventually in middleware once that lands).

@Hansenq
Copy link

Hansenq commented Feb 26, 2023

@brophdawg11 I just filed an issue with the <Link> component improperly handling URLs in only Webkit browsers in 1.13.0. The linked issue does not occur in Chromium, nor on 1.12.0.

The linked issue is a regression, since it does not occur in 1.12.0. The commit fixing this issue looks likely to be the culprit; any chance you could double check? Thanks!

@brophdawg11 brophdawg11 removed the awaiting release This issue has been fixed and will be released soon label Apr 21, 2023
@lili21
Copy link
Contributor

lili21 commented Mar 1, 2024

I ran into similar issue. I'm trying to deploy the remix app to our company cloud service. it works locally, but not in cloud. what should I look at first? below is the error message

TypeError: Invalid URL
    at new NodeError (node:internal/errors:405:5)
    at new URL (node:internal/url:637:13)
    at createRemixRequest (/opt/bytefaas/toutiao/app/gdserver/node_modules/.pnpm/@remix-run+express@2.6.0_express@4.18.2_typescript@5.3.3/node_modules/@remix-run/express/dist/server.js:74:13)
    at /opt/bytefaas/toutiao/app/gdserver/node_modules/.pnpm/@remix-run+express@2.6.0_express@4.18.2_typescript@5.3.3/node_modules/@remix-run/express/dist/server.js:39:21
    at Layer.handle [as handle_request] (/opt/bytefaas/toutiao/app/gdserver/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/layer.js:95:5)
    at next (/opt/bytefaas/toutiao/app/gdserver/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/route.js:144:13)
    at next (/opt/bytefaas/toutiao/app/gdserver/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/route.js:140:7)
    at next (/opt/bytefaas/toutiao/app/gdserver/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/route.js:140:7)
    at next (/opt/bytefaas/toutiao/app/gdserver/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/route.js:140:7)
    at next (/opt/bytefaas/toutiao/app/gdserver/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/route.js:140:7)

@lili21
Copy link
Contributor

lili21 commented Mar 1, 2024

After some dig in, I found the issue
After deployed in our cloud service, the resolveHost is [fdbd:dc01:b:90::28]:dc01, which isn't a valid URL.

the source code

let resolvedHost = `${req.hostname}${port ? `:${port}` : ""}`;
// Use `req.originalUrl` so Remix is aware of the full path
let url = new URL(`${req.protocol}://${resolvedHost}${req.originalUrl}`);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants