Reputation: 3283
I've just read this article about Flask and using Svelte frontend with a separate API specifically the section calledFrontend Served Separately (cross-domain)
They are creating a CSRF cookie and header X-CSRFToken and I'm just built something similar using FastAPI.
Is this actually any more secure because couldn't a bad actor:
I know I must be missing something but I am confused. The code in question is:
@app.route("/api/getcsrf", methods=["GET"])
def get_csrf():
token = generate_csrf()
response = jsonify({"detail": "CSRF cookie set"})
response.headers.set("X-CSRFToken", token)
return response
Upvotes: 0
Views: 35