【发布时间】:2020-11-30 11:03:04
【问题描述】:
我的 CORS 有一个大问题,我测试了很多东西,但我无法解决问题。
我使用 API Platform 和 nelmio cors,这是我的配置
nelmio_cors:
defaults:
origin_regex: true
allow_origin: ['%env(CORS_ALLOW_ORIGIN)%']
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
allow_headers: ['Content-Type', 'Authorization', 'X-LOCALE','Content-Language']
expose_headers: ['Link']
max_age: 3600
paths:
'^/': null
CORS_ALLOW_ORIGIN 我使用 、. 和任何可能的模式(例如 http://localhost:[0-9]+)进行了测试 从前面,我使用Angular 我想在backend/public/images/business-profile/file.png 下获得一个文件存储
我使用服务
getFile(){
return this.httpClient.get('http://localhost:8000/images/business-profile/5f19ca78de1b5563889896.png')
}
然后进入我用来获取它的应用组件
this.testService.getFile().subscribe(
(resp) => {
this.file = resp;
}
)
当我看到浏览器时,我有这个
【问题讨论】:
-
请以可读的形式分享错误消息以及您的调试尝试
标签: angular symfony cors api-platform.com