Amazon CloudFront URL问题

编程入门 行业动态 更新时间:2024-10-10 09:22:50
本文介绍了Amazon CloudFront URL问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用Amazon CloudFront提供我的前端。我的后端在Amazon EC2上运行。

I use Amazon CloudFront to provide my frontend. My backend runs on Amazon EC2.

我为CloutFront分配了自己的域,并设置了 CNAME 条目。在后端,我将新域添加为允许的原始主机。但是现在我收到 crossorigin 错误消息。

I assigned CloutFront a domain of its own and set the CNAME entry. In my backend I added the new domain as allowed origin host. But now I get crossorigin error messages. Why might that be?

推荐答案

请确保您具有以下设置:

Make sure you have following setup:

  • 使用Origin头直接在EC2上进行卷曲,看看是否收到CORS响应。 (对于OPTIONS请求)
  • 在CloudFront上允许OPTIONS请求。
  • 在CloudFront上白名单的原始标头。
  • CloudFront默认情况下会转发Origin头,但它不会将Origin头考虑到缓存键中,这意味着如果您第一次发出不带Origin头的请求www.example/test,CloudFront会缓存它,而下一个请求都带有Origin头,它是从Cache提供服务的,请确保在进行这些更改后清除缓存。
  • Make a curl directly on EC2 with Origin header and see if you get the CORS response. (For OPTIONs requests to)
  • OPTIONS requests are allowed on CloudFront.
  • Origin header Whitelisted on CloudFront.
  • CloudFront bydefault forwards Origin header but it doesn't consider Origin header into the cache key which means if you first make a request www.example/test without Origin header, CloudFront caches it and for the next requests comes with Origin header, it serves it from Cache, make sure you clear the cache after making these changes.
  • 5。检查是否没有得到对于CORS请求的4xx响应(使用Mozilla进行测试)。

    5.Check if you're not getting 4xx response for the CORS request (Use Mozilla to test).

    更多推荐

    Amazon CloudFront URL问题

    本文发布于:2023-11-28 06:03:08,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1641221.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:Amazon   CloudFront   URL

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!