jsonresume / jsonresume.org

The mono repo that builds the homepage, utils, ui components, registry and anything else
https://jsonresume.org
73 stars 19 forks source link

CORS error when trying to fetch raw json #77

Closed romaswe closed 4 months ago

romaswe commented 7 months ago

Describe the bug On the getting started page, it's stated:

You can access more raw formats of your resume too!

JSON - https://registry.jsonresume.org/thomasdavis.json
YAML - https://registry.jsonresume.org/thomasdavis.yaml
TEXT - https://registry.jsonresume.org/thomasdavis.txt 

But when i try to fetch it from Javascript i only get CORS error: Access to fetch at 'https://registry.jsonresume.org/thomasdavis.json' from origin 'http://127.0.0.1:1234' 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.

To Reproduce

I have tested using only fetch

fetch("https://registry.jsonresume.org/thomasdavis.json")
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));

And fetch where im setting the header Access-Control-Allow-Origin': '*'

var requestOptions: RequestInit = {
        method: 'GET',
        headers: {
            'Access-Control-Allow-Origin': '*',
            'Accept': 'application/json'

        },
    };
    var test = fetch("https://registry.jsonresume.org/thomasdavis.json", requestOptions)
        .then(response => response.text())
        .then(result => console.log(result))
        .catch(error => console.log('error', error));

Expected behavior I would expect that i can fetch the raw format of the resume to be able to use the resume in more then one way.

thomasdavis commented 4 months ago

@romaswe just merged #91 which allows any of the dynamic resume requests to be available over an open policy cors e.g. .json, .yaml