Closed (works as designed)
Project:
API Client
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Nov 2023 at 17:32 UTC
Updated:
4 Dec 2023 at 18:42 UTC
Jump to comment: Most recent
When porting our readme example to this code sandbox: https://codesandbox.io/s/drupal-api-client-json-api-client-configuration...
I noticed that using a custom header threw a type error. There seems to be a type guard restricting things to known http headers. I'm not positive that this is an us problem, but wanted to capture it in case. This is a use case in the decoupled kit starter kits.
If we can't fix this ourselves, we might need to update the example in the readme so folks don't run into this.
Comments
Comment #2
coby.sher commentedI can reproduce this with a codesandbox but I see a better error message when trying this locally with the example:
Access to fetch at 'https://dev-drupal-api-client-poc.pantheonsite.io/es/jsonapi/node/recipe/35f7cd32-2c54-49f2-8740-0b0ec2ba61f6' from origin 'http://localhost:5173' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabledLooks like setting a custom header breaks the CORS? This one is beyond me a bit but I think the setting a custom header itself is working and this is a config issue one way or another. I'm going to mark this as closed.
This does highlight to me that we need better error handling throughout.