Edge-CSRF: CSRF protection for Next.js middleware (edge runtime) #38257
Unanswered
amorey
asked this question in
Show and tell
Replies: 1 comment 4 replies
-
Looks good to me! Please can you add typings for Typescript? |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi Next.js Folks!
Recently I wanted to add CSRF protection to my Next.js app but I couldn't find any plugins that ran in middleware or that didn't require a custom Next.js server (e.g. csurf), so I created a new project to solve this problem:
https://github.com/amorey/edge-csrf
Edge-CSRF uses the same strategy and crypto logic from expressjs/csurf and pillarjs/csrf but it only uses edge runtime dependencies so it can be used in Next.js middleware. You can play around with it now but it needs a few more usability features to make it production-ready. In any case, I wanted to get some feedback before I put more effort into it. In particular,
Here's a preview of how you would add it to your middleware:
Let me know what you think!
Beta Was this translation helpful? Give feedback.
All reactions