C
C
claus_bor2017-08-24 23:25:48
JavaScript
claus_bor, 2017-08-24 23:25:48

How to cross request in axios?

The api runs at localhost:8000 front on localhost:3000. For queries I use axios.
Gives the following error:

XMLHttpRequest cannot load http://localhost:8000/api/customers. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.


How to allow to make requests to another domain?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan, 2017-08-25
@LiguidCool

You need to write origin (' Access-Control-Allow-Origin' ) in the header of the server response. These are the addresses of hosts to which external requests are allowed.
For example Node or php .

C
Coder321, 2017-08-25
@Coder321

npm i cors - - save
app.use(cors())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question