This is driving me insane. I am trying to send a simple request to my api server and appending the header. It is first giving me this Provisional Headers are shown message then it will fail on the next request
Provisional headers are shown
Accept: application/json, text/plain, */*
Access-Control-Allow-Credentials: true
Cache-Control: no-cache
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Pragma: no-cache
Referer: https://mywebsite.com/
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36
If I add the below data in my intercept method then I get the error.
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
request = request.clone({ headers: request.headers.set('Access-Control-Allow-Credentials', 'true') });
request = request.clone({ headers: request.headers.set('Cache-Control', 'no-cache') });
request = request.clone({ headers: request.headers.set('Pragma', 'no-cache') });
request = request.clone({ headers: request.headers.set('Expires', 'Sat, 01 Jan 2000 00:00:00 GMT') });
return next.handle(request);
}
If I remove it and do not add the headers then I don't get an error but eventually I will need to send other data in the header like an authtoken and user id. Why am I getting this 405 error when appending to the headers?
Also why is it telling me method not allowed when I clearly am allowing Options and Post methods