Ajax Request header field Key is not allowed by Access-Control-Allow-Headers

后端 未结 3 1500
广开言路
广开言路 2021-02-04 06:21

Trying to build a DNN Service Framework WebAPI but I\'m having trouble consuming it with CORS. I have all of the appropriate headers (I think) but it still doesn\'t seem to be w

3条回答
  •  天命终不由人
    2021-02-04 07:12

    Your server responds with the following custom header to the preflight request:

    Access-Control-All-Headers: Origin, X-Requested-With, Content-Type, Accept, Key
    

    whereas if you (or the person who wrote this server) read carefully about CORS he should have responded with:

    Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Key
    

    Now the client client could go ahead and use the Key custom header.

    This being said, Bearer is quite specific to OAuth 2 which is sent throughout the Authorization header. Using Key seems like a terrible violation of RFCs and stuff and a wheel reinvention kinda.

提交回复
热议问题