-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
Port added to Domain #658
Comments
I unfortunately don't have any experience with Caddy. To look into this, it would be required that a reproduction is available that demonstrates incorrect behavior on the We have quite an extensive test suite for the middleware. If you have a special use case, you can try to add a test there to see if the bug is caused by |
Thank you for your report. Unfortunately, the reproduction is missing or incomplete, and as such we cannot investigate this issue. Please add a reproduction to the issue, otherwise it will be closed automatically. Templates: Creating a good bug report takes time. To help us resolve the issue quickly, please simplify the reproduction as much as possible by removing any unnecessary code, files, and dependencies that are not directly related to the problem. The easier it is for us to see the issue, the faster we can help you. Apart from the reproduction, make sure to include the precise steps on how to reproduce the issue, e.g.:
Thank you for your understanding! FAQ"I've included a reproduction, what is missing?" This comment might have been added because your reproduction doesn't point to either a CodeSandbox or a public GitHub repository where the issue can be reproduced. Please make sure:
|
This is happening to us using Docker Compose and using domains like es.midomain.com > mx.mydomain.com |
I'm also getting this issue, v3.1.3, not using anything fancy like Docker Compose or Caddy. The port is being appended at some point in the domain-based redirect |
Do you have any example code how you did that @7thkey? Would be great, thank you! |
I think I found the issue. If tests pass in #662, this will be fixed in the next patch version. |
Was it fixed? I keep getting port added after upgrading next-intl package |
@Quackzoer Can you open a new issue with a reproduction and more details about your setup? |
@amannn unfortunately the fix ... next-intl/packages/next-intl/src/middleware/middleware.tsx Lines 97 to 104 in 553b8f4
... breaks domain-based routing when Next.js isn't running on standard HTTP/HTTPS port, and isn't behind a proxy. For instance, when running a dev server (port This one test: next-intl/packages/next-intl/test/middleware/middleware.test.tsx Lines 2454 to 2466 in 59cd8dc
... would benefit from another to ensure that, in the absence of it('uses the correct port and protocol', () => {
middleware(
createMockRequest('/', 'fr', 'http://192.168.0.1:3000')
);
expect(MockedNextResponse.next).not.toHaveBeenCalled();
expect(MockedNextResponse.rewrite).not.toHaveBeenCalled();
expect(MockedNextResponse.redirect.mock.calls[0][0].toString()).toBe(
'http://192.168.0.1:3000/fr'
);
}); Footnotes |
@awkaiser-tr Thanks for digging into this and proposing a solution! I agree that it might be reasonable to assume that if there are no |
…p doesn't run behind a proxy (#979 by @awkaiser-tr) Fixes #658 ---- # Contribution feedback @amannn to preserve your desired formatting, this project would benefit from an [EditorConfig](https://editorconfig.org/) or tool such as [Prettier](https://prettier.io/) --------- Co-authored-by: Jan Amann <[email protected]>
@amannn interestingly enough, this 'fix' actually gives issues for us on Railway. Maybe a better solution would be to add it as a config somewhere. |
@pepijn-vanvlaanderen there are multiple patches related to this issue, can you be specific:
|
Hi @awkaiser-tr, thanks for your reply. I have opened an issue here: #987 |
this is not fixed for me 😭 |
@martijnmichel You might want to make sure your reverse proxy is configured correctly (see above). If |
Description
I use the middleware with domain-based routing and have the problem that the port is appended to the domain on my server when the domain is entered without a prefix.
For example:
frontend.domain.com => frontend.domain.com:3000/en
frontend.domain.ca => frontend.domain.ca:3000/fr
I use Caddy as a reverse proxy. If I enter the entire address including the language prefix (e.g. frontend.domain.com/en) it works without any problems and the port is not appended.
Mandatory reproduction URL (CodeSandbox or GitHub repository)
NA
Reproduction description
Next.js 14.0.3, next-intl 3.0
Domain Config:
Middleware:
Caddyfile:
Expected behaviour
The port will not be appended to the domain if I enter the domain without language prefix.
The text was updated successfully, but these errors were encountered: