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
After updating to v3.11.1 rewrite/redirects append a port to the URL #987
Comments
@pepijn-vanvlaanderen your suggestion of config to control what port is used may be the way to go, but it's also possible that the current logic is suboptimal. To troubleshoot further, what request headers are available to Next.js? Do you have values for any of the
... or a |
@pepijn-vanvlaanderen Sorry for the inconvenience caused by this change! But yes, as @awkaiser-tr has pointed out, it would be important to get details about the specific request headers your app receives. Based on that, we can add a failing test like @awkaiser-tr did in #979 and look into an appropriate fix. I'd really like to avoid config as much as possible if we can, therefore the best option from my perspective would be to just do the right thing based on the information we have available. Can you also share your @awkaiser-tr Can you too share your |
My {
defaultLocale: 'de-DE',
domain: getDomain('de-DE').host,
locales: ['de-DE'],
},
{
defaultLocale: 'en-CA',
domain: getDomain('en-CA').host,
locales: ['en-CA', 'fr-CA'],
},
{
defaultLocale: 'en-GB',
domain: getDomain('en-GB').host,
locales: ['en-GB'],
},
// ... and so on ... ... where
|
@amannn are you suggesting an optional Since most deployments will be reached via standard HTTP (80) / HTTPS (443) port, treating non-standard ports as outliers that require config makes sense and would probably result in fewer issues filed on this project.1 However, if { // For sake of discussion ...
defaultLocale: 'en-CA',
domain: getDomain('en-CA').host, // `'www.yourcompany.ca'` || `'ca-yourcompany-dev.localhost'`
locales: ['en-CA', 'fr-CA'],
protocol: getDomain('en-CA').protocol, // `'https://'` || `'http://'`
port: getDomain('en-CA').port, // `undefined` || `3000`
}, ... where by default Footnotes
|
Yep, that's correct. We currently use the protocol and port of an incoming request to determine wether to add it to a domain that we're redirecting to. I was wondering if the port could even be part of An explicit port in the domain config should also give users more flexibility, maybe one domain runs on a different port than another domain. I think this might be a reasonable path forward without having to rely on detecting a reverse proxy, which seemingly people have different configurations for. What do you think? |
Hi @amannn , hereby my domains config:
As you can see, we currently only support 1 language as we are still waiting on translated content, but internally we use @awkaiser-tr how does your |
Local development w/ locale-based domains@pepijn-vanvlaanderen the
|
Agreed, that would be overloading
Adding |
@pepijn-vanvlaanderen Can you share which request headers your app receives in your Railway setup? Maybe you can add some logging in the middleware? I did some research and it seems like Railway uses Envoy, which in turn should support Supporting different ports for different domains as discussed above could be interesting, but for now, the easiest fix might be to apply ports correctly when running behind a reverse proxy. It would be helpful to learn if Railway is accidentally stripping important headers here of if the middleware logic of With the fix from @awkaiser-tr in #979 we now have this logic:
It would be interesting to learn about the exact values of these request headers in your app to diagnose where the issue is. Can you share them? Thanks! |
Hi @amannn, after some testing I see now that the issue occurs on the pathname rewrite. So i.e. I have in pathnames this:
For all (custom) domains it will work, except for the nl (Dutch) variant. It will take some long time loading and end up at When logging the x-forwarded-host and x-forwarded-port on Railway, I get these results:
|
@amannn funny enough, I just experienced the same bug RE: localized pathname redirects 💣 @pepijn-vanvlaanderen quick sanity check: I see you're reporting |
@awkaiser-tr for all the requests the port is set as 3000 and the domain I have set per locale as the host. |
Same problem for us, when updating to 3.11.1, for all locales: After update (port added to URL): Before update (correct pathname translation for locale): |
@pepijn-vanvlaanderen Are you saying that for a request to See also:
(source) Can you verify this with Railway? @awkaiser-tr Does this match your understanding too? @TomasLukes Which hosting provider are you using? Can you also double check what the value of |
Hi @amannn, thanks for your message. Actually I think the issue then is probably how I had setup the Dockerfile. There is a reverse proxy in front of the container and inside the container it then uses the mentioned port. Maybe Railway should superseed that from the proxy, but in the meantime I was just able to expose port 443 in the dockerfile instead of 3000 and it works now, thanks! |
Yup. @pepijn-vanvlaanderen when you say "it works now" do you mean that, in addition to your other routes, the This GitHub Issue has been confused since details have changed over time:
|
Thanks for quick help!👌 "x-forwarded-port" value in middleware is 3000 now. Should I do something like this? It looks like its behaving correctly after that 🤔 |
@TomasLukes just as Pepijn did, I'd recommend digging deeper and determining why the |
@awkaiser-tr yes the redirect also leads to localized pathnames correctly. The undesired port issue originated from a bad config. I exposed port number 3000 in the production environment before, and thats why it redirected to the domain with port addition after reading |
Description
The last change for internal redirecting appends a port to the URL. However in our setup at Railway.app this does a faulty redirect. When the middleware should rewrite / redirect, it takes a long time and eventually redirects to the correct URL but with the port number and that crashes.
Reverting to v3.11.0 works.
Verifications
Mandatory reproduction URL
https://yeahgummy.webbers.dev/cart
Reproduction description
Steps to reproduce:
https://yeahgummy.webbers.dev:3000/winkelwagen
Expected behaviour
A redirect to
https://yeahgummy.webbers.dev/winkelwagen
showing a page.The text was updated successfully, but these errors were encountered: