I'm trying to automate logging in to a website by posting the username and password throug a request. But i get an error from the website:
{ "detail": "CSRF Failed: Referer checking failed - no Referer." }
When adding a header like:
Dim request = MyWebview2.CoreWebView2.Environment.CreateWebResourceRequest("https://example.com/auth/login/", "POST", postDataStream, "Referer: https://example.com/auth/login/")
MyWebview2.CoreWebView2.NavigateWithWebResourceRequest(request)
or with
request.Headers.SetHeader("Content-Type", "application/json")
request.Headers.SetHeader("Referer", "https://example.com/auth/login/")
MyWebview2.CoreWebView2.NavigateWithWebResourceRequest(request)
i still get the above 'no Referer"-error.
When I check with Developer Tools I indeed see the WebView doesn't send along the referer with the request. Anything other in the header will be added to the request:
request.Headers.SetHeader("foo", "bar")
Am I not allowed to "fake" the referer? In Postman I can set the referer without problems and login automated.