remix
remix copied to clipboard
Redirecting to utf8 URLs causes an internal server error
What version of Remix are you using?
2.1.0
Are all your remix dependencies & dev-dependencies using the same version?
- [X] Yes
Steps to Reproduce
In a loader, call something like
throw redirect(encodeURI(`/ಠ`));
Expected Behavior
It redirects to the URL, /ಠ
Actual Behavior
You get an internal server error:
Unexpected Server Error
TypeError: Cannot convert argument to a ByteString because the character at index 15 has a value of 3232 which is greater than 255.
This is, fwiw, kind of reasonable - the Location HTTP header does require that its value is a ASCII.
However, I think at this level of interface, this is pretty unexpected: you're redirecting to a URL, not setting a Location header. It makes sense, I think, to call internally encodeURI() to escape any non-ASCII characters in the redirect target, rather than expecting the API consumer to do that anywhere that a redirect is used.
@tmcw Tested this on the last remix version, seems to be working fine, and I'm being redirected to /ಠ
Is this fixed for you as well ?
This issue has been automatically closed because we haven't received a response from the original author 🙈. This automation helps keep the issue tracker clean from issues that are unactionable. Please reach out if you have more information for us! 🙂
Faced similar issue. OP's post states the issue and fix, it's just labeled incorrectly
This will create an error
throw redirect(`/ಠ`);
This will fix it
throw redirect(encodeURI(`/ಠ`));