Node api returns status 0 when I try it from the browser, everything fine with postman

Hi

I’m having issue with my first app which I can’t resolve.
on the back end I’m have the code:

app.get('/', (req, res) => res.send('Hello World!'));

and on front end I’m trying to catch that hello world with:

fetch('http://127.0.0.1:3000', {
    mode: 'no-cors',
  }).then((response) => console.log(response));

The response I’m getting is:

Response {type: "opaque", url: "", redirected: false, status: 0, ok: false, …}
body: (...)
bodyUsed: false
headers: Headers {}
ok: false
redirected: false
status: 0
statusText: ""
type: "opaque"
url: ""
__proto__: Response

So you can see there is status code 0. When I tested back end with postman it returned Hello World with status code 200 OK but from browser it doesn’t and I can’t figure out what is the problem.
I added “mode: no-cors” because I was getting that error.

I think it is the mode option that is causing that.

https://fetch.spec.whatwg.org/#concept-request-mode
https://fetch.spec.whatwg.org/#concept-filtered-response-opaque

Try adding the cors package, require it in and use it, remove the option in the fetch.

thx @lasjorg!
adding cors middleware solved the issue .