Skip to content

Fixed the issue in proxy.js#1

Open
PreethiPantangi wants to merge 1 commit into
cosieLq:mainfrom
PreethiPantangi:main
Open

Fixed the issue in proxy.js#1
PreethiPantangi wants to merge 1 commit into
cosieLq:mainfrom
PreethiPantangi:main

Conversation

@PreethiPantangi

Copy link
Copy Markdown

Fix provided in proxy server to clean multiple slashes and correctly redirect with HTTP 308

Description:
This PR updates the proxy server logic to:
• Detect multiple consecutive slashes (//, ///, etc.) in the incoming URL.
• Clean the URL by replacing extra slashes with a single slash.
• Redirect the browser using an HTTP 308 Permanent Redirect to the cleaned URL.
• Prevent forwarding malformed URLs to the Next.js application.

Previously, malformed URLs (with extra slashes) were either forwarded incorrectly or caused client-side router crashes with error message “Error: invariant: invalid relative URL, router received...”.

Tested:
• Manually tested with URLs like http://localhost:8000///about and http://localhost:8000///de/////about and confirmed redirection to http://localhost:8000/about and http://localhost:8000/de/about respectively.
• Confirmed correct behavior in incognito mode and after clearing browser cache.
• Tested proxy with HTTPS using sample PEM keys.

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 this pull request may close these issues.

1 participant