CORS error on docs.jsonld
See original GitHub issueAPI 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
These are the headers for the /api/docs.jsonld
request:
The full error output on console:
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 withcurl -sS https://get.symfony.com/cli/installer | bash
and finally runsymfony 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.
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!