Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

Angular proxy shows request header failed error

Hi I am trying to create an angular proxy. The current setup directs or route traffic from the landing page to the backend services and I am using the following documentation from angular site: https://angular.io/guide/build#proxying-to-a-backend-server. I am using the proxy.conf.js since I have to route traffic to different paths. Currently seeing the following error:

Access to XMLHttpRequest at 'https://backend-service.customdomain.net/security/v1/users/signon' from origin 'https://10.10.10.4' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.

My proxy.conf.js looks like this

proxy.conf.js

const PROXY_CONFIG = [
    {
        context: [
            "/admin",
            "/security",
            "/event-log",
            "/converter"
        ],
        target: "https://backend-service.customdomain.net",
        secure: false,
        changeOrigin: true,
        logLevel: "debug",
        headers: {"Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "*", "Access-Control-Allow-Methods": "POST, GET, PUT, OPTIONS, DELETE", 'X-Requested-With' :'XMLHttpRequest'},
    }
]

module.exports = PROXY_CONFIG;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...