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.

CORS error on docs.jsonld

See original GitHub issue

API Platform version(s) affected:“@api-platform/admin”: “^1.0.2”

Description
It’s able to access /api route and retrieve info but fails to access route /api/docs.jsonld throwing CORS error.

How to reproduce
Full code in this repository, but in summary:

The API is running at PHP serve php -S 127.0.0.1:8001 -t public, while the admin is running on http://localhost:3000/

/config/packages/nelmio_cors.yaml

 nelmio_cors:
defaults:
    origin_regex: true
    allow_origin: ['^https?://localhost:[0-9]+.*|127.0.0.1(:[0-9]+)?']
    allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
    allow_headers: ['Content-Type', 'Authorization']
    expose_headers: ['Content-Disposition','Link','X-Total-Count']
    max_age: 3600
paths:
    '^/': ~

Possible Solution

Additional Context
This is the output of the /api call, than happens immediately before calling /api/docs.jsonld Screenshot 2020-01-12 at 3 36 56 PM

These are the headers for the /api/docs.jsonld request:

Screenshot 2020-01-12 at 3 38 38 PM

The full error output on console:

Screenshot 2020-01-12 at 3 40 09 PM

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
BernardAcommented, Jan 23, 2020

My last attempt was changing the server. I was using the PHP server as php -S 127.0.0.1:8001 -t public. I installed the Symfony binary with curl -sS https://get.symfony.com/cli/installer | bash and finally run symfony server:start.

It works fine now. Not sure what the problem is though. I would suggest your docs to advise not to user the PHP server. That would save people a lot of pain.

0reactions
baspeeterscommented, Jul 11, 2020

I have the same issue, except I’m not even using the admin module, I’m just trying to generate client files for the API Platform Client Generator.

Regardless, @BernardA’s solution worked for me, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Page partially loaded" speakable JSON-LD schema not ...
I've added the JSON-LD "speakable" schema ... if it makes it clearer for you https://developers.google.com/search/docs/data-types/speakable.
Read more >
Get or set a CORS JSON document for one or more buckets
Gets or sets the Cross-Origin Resource Sharing (CORS) configuration on one or more buckets. This command is supported for buckets only, not objects....
Read more >
JSON-LD: Context for your Data > API Platform - SymfonyCasts
A typical API returns JSON. Go to /api/cheese_listings/2.json . When I think of an API, this is what I traditionally picture in my...
Read more >
React-admin + api-platform - Content-Range - Stack Overflow
I can see the table to items, but when I try to load items from backend, I see all time the same bug:...
Read more >
JSON-LD Community Group
https://github.com/json-ld/yaml-ld/issues/12 -> Issue 12 Convert JSON-LD to ... about whether you process one, or multiple JSON-LD docs.
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