S
SolidJS4mo ago
Untlsn

[h3] [unhandled] TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["X-Error"]

For some reason in dev mode i cannot throw errors in server functions. After build it work as expected. For some reason i get this error always, but i cannot find anyone with same problem
1 Reply
Untlsn
UntlsnOP3mo ago
After some digging i find out that this error is more helpful then expected This error is thrown when i used special letter in message (in my case Polish ł and ą in word "Błąd") Maybe there is a way to remove X-Error or change it to true like when throwing json with status >= 400? I founded temporary workaround If I wrap error with json function it return X-Error as true and error in body without issue Or even better and probably correct answer Just encode message before sending and decode before displaying encodeURI and encodeURIComponent work the same in that case From little testing special characters like /?: aren't throwing this error So probably encodeURI is slightly better because it encode less characters, but i don't know

Did you find this page helpful?