Encoded URI with slashes doesnt work in server but works in localhost
Unanswered
American Shorthair posted this in #help-forum
American ShorthairOP
Hello,
I am using the app router with dynamic route segments, e.g [productSlugs]. these segments may contain a / and thus I am using encodeUriComponent client-side to escape it. The resulting URL then contains %2F instead of the slash.
This seems to work for localhost (when running next dev) however on the compiled variant using next build it does not work. It seems like %2F is again intepreted as / and I end up in a 404 page.
The same problem is also described here: https://stackoverflow.com/questions/79383014/encoded-url-with-special-characters-work-on-localhost-but-not-when-deployed-to-s
Any suggestions of what could be changed?
I am using the app router with dynamic route segments, e.g [productSlugs]. these segments may contain a / and thus I am using encodeUriComponent client-side to escape it. The resulting URL then contains %2F instead of the slash.
This seems to work for localhost (when running next dev) however on the compiled variant using next build it does not work. It seems like %2F is again intepreted as / and I end up in a 404 page.
The same problem is also described here: https://stackoverflow.com/questions/79383014/encoded-url-with-special-characters-work-on-localhost-but-not-when-deployed-to-s
Any suggestions of what could be changed?
1 Reply
American ShorthairOP
Seems like the issue stems from azure app service decoding the url before it reaches the nextjs app. https://learn.microsoft.com/en-us/answers/questions/1160320/azure-is-decoding-characters-in-the-url-before-rea