I found out from this link that the Http Request Header's max size For a NodeJS server, is 80KB. And my Node + Express server crashes after such OPTIONS preflight request is received.
In my Angular App, using HttpClient
, all my requests look something like this:
import { HttpClient } from '@angular/common/http';
const httpOptions: { headers: HttpHeaders } = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Authorization': 't0ken-g1bber1$h-c0m!nG-kabdjasbgdjlashndashdasdfghjxcnqwezxc'
//Token is taken from localStorage after login. Hardcoded here for simplicity.
})
};
//Example Request
this.http.get<any>('http://myDomain/endpoint', httpOptions)
How do I make a correct request that will not cause this problem? Is there something wrong with how I used the HttpClient
?
According here, The service I'm using (In this case, I'm simply using Angular's HttpClient) has made a mistake by putting too much data in a header.