In my local environment, it works fine when I wrap it in quotes, but it seems like that doesn't work in Vercel. Is there a fix for this? I already tried escaping it with \.
Thanks!
Leaderboard GOATAccepted answer(edited)
Try using double quotes, too, just to see if it works ("VALUE" instead of 'VALUE'). If that does not work, you could encode it as a Base64, which will eliminate the # character, and decode the Base64 to a normal string in your code.
1const encodedToken = process.env.TOKEN;2const decodedToken = Buffer.from(encodedToken, "base64").toString("utf-8");34// Do something with the decodedToken!
If that does not work, you could encode it as a URI, which should also eliminate the # character, and decode the URI to a normal string in your code.
URI Encoding Example (does not work for this specific case)
1const encodedToken = process.env.TOKEN;2const decodedToken = decodeURIComponent(encodedToken);34// Do something with the decodedToken!
Base64 encoding did the trick, thanks!
It seems weird that not a lot of people are opening issues about this, tokens usually have all sorts of weird characters, there should be some sort of manual escaping in the Vercel dashboard.
Leaderboard GOAT
Awesome!
Also, did URI encoding not work? Perhaps I should update my answer with Base64…
No, it didn't for some reason.
Leaderboard GOAT
Thanks for letting me know, I updated the answer. 🙂
This topic is closed. It no longer accepts new replies.