0
votes
ERROR ReferenceError: Headers is not defined

when i run the command node dist/server.js it says that Node server listening on http://localhost:4000. but when i load http://localhost:4000 in the browser, the Headers is not defined error comes

1

1 Answers

0
votes

You need to provide a request to your browser code

app.browser.module.ts

...
// the Request object only lives on the server
export function getRequest(): any {
  return { headers: { cookie: document.cookie } };
}
...

 providers: [
    {
      // The server provides these in main.server
      provide: REQUEST,
      useFactory: getRequest,
    },
    { provide: 'ORIGIN_URL', useValue: location.origin },
  ],