Error: The edge runtime does not support Node.js 'crypto' module.
Answered
LaPerm posted this in #help-forum
LaPermOP
In my 'middleware.ts', I was trying to get authentication header and decode it. I am using 'jsonwebtoken' library to create and validate jwts. But it would appear I can not use jsonwebtoken.verify() in my middleware as it requires Node.js runtime. Is there any way to switch to Node.js runtime from Edge runtime, or is there any other solution to my problem?
Sorry if my question is stupid!
Sorry if my question is stupid!
Answered by Asian black bear
No, you can't change the runtime and have to use a library that is Edge-compatible. If I'm not mistaken
jose
can be used.2 Replies
Asian black bear
No, you can't change the runtime and have to use a library that is Edge-compatible. If I'm not mistaken
jose
can be used.Answer
LaPermOP
Thanks! jose exactly fixes this problem. Additionally I had to pass the token secret as utf-8 encoded buffer. I have attached the solution for anyone sharing the same problem.