Я пытаюсь настроить мое приложение angular-cli на использование прокси, поэтому мне не требуется CORS на моем веб-сервере.
мой сервер DotNetCore работает на порту 49274. мое приложение angular-cli работает на 4200
Я почти уверен, что прокси-сервер существует для удаления ошибок CORS ...
, но я все еще получаю ошибки CORS ...
beer/list:1 Failed to load http://localhost:49274/api/beer: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
core.js:1601 ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: null, ok: false, …}
Здесьсписок настроек, которые я пробовал ...
{
"/api": {
"target": "http://localhost:49274",
"secure": false
}
}
{
"/api/*": {
"target": "http://localhost:49274",
"secure": false
}
}
{
"/api": {
"target": "http://localhost:49274",
"secure": false,
"changeOrigin": true
}
}
{
"/api/*": {
"target": "http://localhost:49274",
"secure": false,
"changeOrigin": true
}
}
{
"/api": {
"target": "http://localhost:49274",
"secure": false,
"changeOrigin": true,
"pathRewrite": {"^/api" : "http://localhost:49274/api"}
}
}
{
"/api/*": {
"target": "http://localhost:49274",
"secure": false,
"changeOrigin": true,
"pathRewrite": {"^/api" : "http://localhost:49274/api"}
}
}
{
"/api": {
"target": "http://localhost:49274",
"secure": false,
"changeOrigin": true,
"pathRewrite": {"^/api" : ""}
}
}
{
"/api/*": {
"target": "http://localhost:49274",
"secure": false,
"changeOrigin": true,
"pathRewrite": {"^/api" : ""}
}
}