1

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.

Cold Cerberus
  • 1,685
  • 14
  • 35
  • Why are your headers so ridiculously large? – Evert Dec 14 '18 at 05:10
  • No Idea. as I've shown in the example code, that's the only content of my header. Maybe there's something wrong with the service it self or there's should be an additional config on the server side. Still figuring it out now. – Cold Cerberus Dec 14 '18 at 05:18
  • Yea it sounds like there would be, because those headers don't add up to 80kb. – Evert Dec 14 '18 at 15:26
  • Did you inspect the network tab and confirm that the header is actually 80kb, because your source code example has a small header. JWT tokens are much larger as an example. – Reactgular Dec 15 '18 at 02:03

0 Answers0