Answer the question
In order to leave comments, you need to log in
Failed to fetch - Node.js?
Hello. When I go, for example, through a browser to the address example.com:6470, I get "Hello World", listening to the port is started via express.
But when I try to make a request with a third-party script, either via fetch() or via request() to the same address, it sends a "Failed to fetch" error, what could be the problem?
Answer the question
In order to leave comments, you need to log in
Connect the cors npm install cors
package to express and use app.use(cors()) before the routes. And he runs into another problem. req.body for some reason is only there if you submit the form from the current domain, he just started to study this stack for this xs why. To read data, you need the body-parser package. How to connect infa is in the docks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question