Answer the question
In order to leave comments, you need to log in
How to set proxy for backend in angular 2 cli?
I use openserver as backend.
The essence of the error: when going to the address localhost:4200/api, an error occurs Object Not Found Error 404
Creating a proxy.conf.json file with the content:
{
"/api": {
"target": "http://test.ru",
"secure": false
}
}
Answer the question
In order to leave comments, you need to log in
If the request from localhost:4200/api/foo/bar
should fly to http://test.ru/foo/bar
- then you need to add a line. And I would like to add one more.
{
"/api": {
"target": "http://test.ru",
"pathRewrite": { "/api": "" }, // this line
"changeOrigin": true, // and this too
"secure": false
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question