Error: The response has no "Link" HTTP header.
See original GitHub issueHello, It’s my first project using Symfony framework and i’am new with api-platform & admin-on-rest. So for now, i have entities and i build my api with api-platform. Now, i want integrate an admin interface in my project. So i followed the getting starting introduction here https://github.com/api-platform/admin and i replaced entrypoint with my own local api url ‘http://localhost:8000/api/v2’.
1st i was that error : Fetch API cannot load http://localhost:8000/api/v2. Response to preflight request doesn’t pass access control check: The ‘Access-Control-Allow-Origin’ header contains the invalid value ‘null’. Origin ‘http://localhost:3000’ is therefore not allowed access. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
So i added the nelmio-cors bundle in my project and i added this in my parameter.yml file :
nelmio_cors:
defaults:
allow_credentials: false
allow_origin: []
allow_headers: []
allow_methods: []
expose_headers: []
max_age: 0
hosts: []
origin_regex: false
forced_allow_origin_value: ~
paths:
'^/api/':
allow_origin: ['*']
allow_headers: ['X-Custom-Auth', 'Content-Type', 'Link']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE', 'OPTIONS']
max_age: 3600
'^/':
origin_regex: true
allow_origin: ['^http://localhost:[0-9]+']
allow_headers: ['X-Custom-Auth', 'Content-Type', 'Link']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE', 'OPTIONS']
max_age: 3600
hosts: ['^api\.']
After, i have that error:
Uncaught (in promise) Error: The response has no "Link" HTTP header.
at getDocumentationUrlFromHeaders (parseHydraDocumentation.js:71)
at parseHydraDocumentation.js:92
at <anonymous>
getDocumentationUrlFromHeaders @ parseHydraDocumentation.js:71
(anonymous) @ parseHydraDocumentation.js:92
How can i fix that ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Might be a bit late of an answer, but adding the configuration below to nelmio_cors should help you out and anyone else running into this issue.
expose_headers: ["Link"]
This actually is my correct Docker IP. There seems to have an issue with my nginx configuration and Nelmio CORS configuration. When I remove additional headers in nginx, the headers added by Nelmio CORS work fine until I generate a non-200 status.