Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS issue #3

Open
ralberth opened this issue Jan 7, 2021 · 2 comments
Open

CORS issue #3

ralberth opened this issue Jan 7, 2021 · 2 comments

Comments

@ralberth
Copy link

ralberth commented Jan 7, 2021

When using the default setup from README.md, I'm getting CORS errors in the browser console. Looking at the code, this makes Ajax calls directly from the browser to the joke web service. I looked over the docs at https://sv443.net/jokeapi/v2/ and they don't support sending CORS headers.

How can I use this with a browser instead of an embedded UI? Thanks.

@Kreshnik
Copy link
Owner

Kreshnik commented Jan 7, 2021

If I understand you correctly, you could execute the code block below in the browser console. Programming is the category name.

fetch(`https://sv443.net/jokeapi/v2/joke/Programming`).then((response) => {
    response.json().then((joke) => {
        console.log(joke)
    });
});

@ralberth
Copy link
Author

ralberth commented Jan 7, 2021

The problem is the missing CORS headers. sv443.net won't allow cross-region requests from a browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants