Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom headers in request? #52

Open
dwbruhn opened this issue Jan 12, 2024 · 2 comments
Open

Custom headers in request? #52

dwbruhn opened this issue Jan 12, 2024 · 2 comments

Comments

@dwbruhn
Copy link

dwbruhn commented Jan 12, 2024

I realize the purpose of this package is to abstract the network calls, though I find I can't use it in conjunction with CSRF protection. It would be awesome to have the ability to customize headers in each call (such as x-csrf-token)!

@Janpot
Copy link
Owner

Janpot commented Jan 12, 2024

Can't the token be passed to the rpc function in one of its arguments?

@dwbruhn
Copy link
Author

dwbruhn commented Jan 12, 2024

That's true, If I were rolling my own CSRF protection, that would work. However, I'm using an off-the-shelf CSRF solution (https://github.com/krakenjs/lusca) that expects the token either in the top level of req.body or in a header:

https://github.com/krakenjs/lusca/blob/741de51c4c61c73a97950e41a282a15e12ebb5a8/lib/csrf.js#L155-L156

If I pass the CSRF token in the params to the RPC function, it gets JSON stringified inside req.body.params[0], which is not something lusca understands:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants