Closed Kishlay-notabot closed 5 months ago
@Kishlay-notabot you have enabled CSRF protection for your Flask server, but then in the client you are not sending a CSRF token.
Thankyou for pointing that out. Do flask wtf forms require csrf tokens generally ?
Yes, for forms it is a good practice to use CSRF protection. But you have enabled it for the entire server.
Oh okay, how do I limit csrf to just the scope of the form?
By creating a seperate forms.py file?
Remove this:
csrf = CSRFProtect(app)
when i try to run the app after removing that, i encounter this error again:
[2024-06-16 17:07:19,427] DEBUG in app: Form errors: {'csrf_token': ['The CSRF token is missing.']}
and this was the main reason i started playing around with csrf. How do i bypass this then?
And this pops up when i fill the form and click submit, There is an error 400 bad request on the console.
Ok so maybe the code I'm running is a mess, if you could just point out where is it going wrong, it would be very nice because I want to learn where did I actually go wrong. Maybe I'll not use flask-wtf for now, but I want to know where the mistake is exactly
Forms are configured to require CSRF by default, you don't have to add anything to your application. How do you submit your forms?
thanks a lot for helping! ill check the resources out
I tried implementing a flask app on my own and im facing an error. Here's the code: app.py:
script.js:
Earlier I didn't include csrf in my project, when i did, i faced a new error, and this wont work. the error is:
script.js:24 An error occurred: SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON
When i open the network tab and see the preview, i see an html render sayingWhy so? I'm a beginner and im confused.