Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular CORS和API平台Symfony存在问题_Angular_Symfony_Cors_Api Platform.com - Fatal编程技术网

Angular CORS和API平台Symfony存在问题

Angular CORS和API平台Symfony存在问题,angular,symfony,cors,api-platform.com,Angular,Symfony,Cors,Api Platform.com,我的CORS有一个大问题,我测试了很多东西,但我不能解决这个问题 我将API平台与nelmio cors一起使用,下面是我的配置 nelmio_cors: defaults: origin_regex: true allow_origin: ['%env(CORS_ALLOW_ORIGIN)%'] allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'] allow_headers: [

我的CORS有一个大问题,我测试了很多东西,但我不能解决这个问题

我将API平台与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_允许_原产地我用、。任何可能的模式,比如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;
  }
)
当我看到浏览器时,我有这个


缩进不正确,默认值和路径在nelmio_cors内

nelmio_cors: 默认值: 来源(regex):对 允许源代码:['%envCORS\u允许源代码%] 允许使用以下方法:[“获取”、“选项”、“发布”、“放置”、“修补”、“删除”] 允许_头:['Content-Type'、'Authorization'、'X-LOCALE'、'Content-Language'] expose_头:['Link'] 最高年龄:3600 路径: “^/”:null
怎么样?请告诉menelmio_cors是此捆绑包的根节点,因此所有实体都必须插入此节点。请参阅文档:我假设这是一个复制/粘贴错误,因为Symfony可能会为这些未知键抛出一个错误?是的,在这种情况下,Symfony应该为每个参数都抛出一个exceptionI测试所有可能的组合,我不知道为什么不运行ok。请以可读的形式共享错误消息,以及您的调试尝试