jacksorjacksor (Richard Jackson)
03/14/2024, 8:25 PMfetch
call with Astro but want to check that it's not an Umbraco issue before asking Astro (the joys of not knowing where the problem lies).
Some details:
- Running both Umbraco and Astro locally
- Calling a fetch
to HTTP endpoint works fine
- Calling a fetch
to HTTPS endpoint returns the Fetch Failed error (image provided)
- In appsettings.json
I have Umbraco.CMS.Global.UseHttps set to true
(unsure if relevant)
- Umbraco version 13.2.0, Windows 11
- It's a Thursday
When using Postman I can successfully make the API call to the HTTPS endpoint, but receive a cautionary "Unable to verify the first certificate" (image provided). The HTTP endpoint is successful and has no caution.
Having just tried a basic JS query I'm actually getting a CORS error, so it might be that. If that's the case, how should I set-up CORS policies for the Content Delivery API?
html
<script>
fetch("https://localhost:44364/umbraco/delivery/api/v1/content")
.then((response) => response.json())
.then((data) => console.log(data));
</script>
Console:
Access to fetch at 'https://localhost:44364/umbraco/delivery/api/v1/content' from origin 'http://localhost:5500' has been blocked by CORS policy: 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 disabled
Thanks in advance!
Rich
https://cdn.discordapp.com/attachments/1217931605331411037/1217931606099103755/error-img.png?ex=6605d232&is=65f35d32&hm=b2d76acb58522f16e5b71fec978dc1e57472e8febdd0c815d7b7bd053aea3184&
https://cdn.discordapp.com/attachments/1217931605331411037/1217931606359146646/image.png?ex=6605d233&is=65f35d33&hm=8721080b581a52ff905c586cc6d77b35837bece5db3880536ddc2c3cef72ea3c&jacksorjacksor (Richard Jackson)
03/14/2024, 8:27 PMjacksorjacksor (Richard Jackson)
03/14/2024, 8:48 PMjacksorjacksor (Richard Jackson)
03/14/2024, 9:39 PMjacksorjacksor (Richard Jackson)
03/15/2024, 10:58 PMNODE_TLS_REJECT_UNAUTHORIZED=0
to stop Node.js from rejecting self-signed SSL certificates locally.
Kenn's repo has all the answers, specifically around using .env.development
and astro.config.mjs
to support local dev. https://github.com/kjac/UmbracoAzureCloudflare