api-platform的管理员"无法检索API文档"

Vin*_*iès 4 admin-on-rest api-platform.com

我尝试使用api-platform的所有功能来测试这个解决方案.我不想使用docker stack来理解构造.

我的测试API现已创建并可用.

API https://ibb.co/hcjyrJ

入口点:http://api.localhost

我的问题是我将使用官方教程安装管理员.

  • 在安装纱线时我没有任何错误或警告

api安装 https://ibb.co/gmK1dy

  • src/App.js用我的入口点修改了文件

api js https://ibb.co/nQKHJy

  • 我修改了API CORS HTTP Headers以允许管理员的域访问它.管理员的域名是http://localhost:3000

api cors https://ibb.co/niH7kd

当我尝试访问admin:时http://localhost:3000,我收到了消息Unable to retrieve API documentation.

我在控制台中没有任何消息.如果我检查我的网络选项卡,我可以使用正确的响应查看对API的调用.

api admin https://ibb.co/injbdy

如果您有任何想法......我会得到它们!

Vin*_*iès 6

我找到了解决这个问题的方法.

nelmio_cors.yaml,你必须添加Linkexpose_headers.

该文件必须如下所示:

nelmio_cors:
defaults:
    origin_regex: true
    allow_origin: ['*']
    allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
    allow_headers: ['Content-Type', 'Authorization']
    expose_headers: ['Content-Disposition', 'Content-Length', 'Link']
    max_age: 3600
paths:
    '^/': ~
Run Code Online (Sandbox Code Playgroud)