question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: The response has no "Link" HTTP header.

See original GitHub issue

Hello, 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:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
cormackcommented, Jun 25, 2017

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"]

0reactions
nicolaskerncommented, Jun 15, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The response has no "Link" HTTP header · Issue #10 - GitHub
I'm using api-platform 2.1beta1 and I have completed all admin instruction steps. I'm getting an error: parseHydraDocumentation.js:71 ...
Read more >
Http response with no http header - Stack Overflow
I have not tried yet to respond binary image files, or gzip compressed file for the moment, in which cases I suppose it...
Read more >
Link - HTTP - MDN Web Docs - Mozilla
The HTTP Link entity-header field provides a means for serializing one or more links in HTTP headers. It is semantically equivalent to the ......
Read more >
HTTP/1.1: Status Code Definitions
This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty...
Read more >
The ultimate guide to HTTP status codes and headers for SEO
Do you understand how HTTP protocol works and the impact it has on ... is literally no limit to what a URL's full...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found