CORS request not working in Safari

后端 未结 13 1476
忘掉有多难
忘掉有多难 2020-11-27 06:04

I am making a CORS xhr request. This works fine in chrome, however when I run in safari I get an \'Can not load ---- access not allowed by Access-control-allow-origin\'.

13条回答
  •  隐瞒了意图╮
    2020-11-27 06:53

    I encountered the same error when making an XHR request against a file in Amazon S3. On Safari 7 it was failing. I know you're not using Amazon S3, but I thought I'd post in case this solution helped others.

    The problem was that Safari 7 set the Access-Control-Request-Headers header to "origin, x-requested-with", but my AWS CORS configuration only allowed "x-requested-with":

    
    
        
            *
            GET
            3000
            Authorization
            x-requested-with
        
    
    

    I added "origin" as an allowed header and everything worked fine.

            origin
    

    Note: the AllowedOrigin of * is for development purposes only. See @andes comment below for more information.

提交回复
热议问题