gpt4 book ai didi

symfony - Safari - 由于访问控制检查,XMLHttpRequest 无法加载 X。 [检查员]

转载 作者:行者123 更新时间:2023-12-04 22:37:50 24 4
gpt4 key购买 nike

情况:
每当您在 中访问此 URL 时 Safari https://nvm.samengroen.com/plan/basic/497并在控制台中查看有关 XMLHttpRequest 的错误和 access control checks .
奇怪的是,当我打开开发者工具并重新加载页面时,它工作正常。
有人可以澄清为什么它可以与打开的开发人员工具一起使用。以及可能导致此问题的原因。
信息:
该项目由 Angular 组成前端 (nvm.samengroen.com) 和 API-Platform Symfony后端(broker-api.samengroen.com)。它们都在同一个通配符 SSL 证书上,我发现这可能是答案,但是登录并查看从 API 获取数据的其他页面没有任何问题。
我们还在 .env 中进行了尝试。文件,没有任何结果:

###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN=^https?://.*?$
###< nelmio/cors-bundle ###
到目前为止我的发现:
我一直在谷歌搜索解决方案,但找不到明确的答案。
https://laracasts.com/discuss/channels/laravel/cors-access-control-allow-origin-issues-on-safari-mobile-and-desktop

google tells me this would probably be because of a combination of

  • HTTP/2 capable browsers
  • multiple domain certificate (probably a wildcard cert)
  • at some point apache wants to renegotiate the TLS which is not supported in the client implementation of http/2


Safari 10.1: XMLHttpRequest with query parameters cannot load due to access control checks

Your server needs to reply to the OPTIONS http method. Not only to GET/POST/PUT/DELETE. Safari silently requests this hidden in the background. You can discover this with a MITM-attack on the connection



编辑#1
因此,在服务器日志中挖掘之后,我发现了以下内容:
AH02032: Hostname nvm.samengroen.com provided via SNI and hostname broker-api.samengroen.com provided via HTTP have no compatible SSL setup, referer: https://nvm.samengroen.com/plan/basic/497
似乎它确实与 SSL 证书和可能的通配符有关。

最佳答案

请将此配置添加到您的nelmio_cors.yaml在配置中。

nelmio_cors:
defaults:
origin_regex: true
allow_origin: ['*']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
allow_headers: ['Content-Type']
expose_headers: ['Link']
max_age: 3600
paths:
'^/api/':
allow_origin: ['*']
allow_headers: ['*']
allow_methods: ['OPTIONS','POST', 'PUT', 'GET', 'DELETE', 'PATCH']
max_age: 3600
在这里,我们允许 OPTIONS请求也是如此。

Note: I am assuming you have all your api's at a prefix of /api/ for all routes

关于symfony - Safari - 由于访问控制检查,XMLHttpRequest 无法加载 X。 [检查员],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62789513/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com