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

fetch fails in javascript kernel when requesting to CORS'ed API #3744

Open
3 of 17 tasks
estalldecker opened this issue Nov 4, 2024 · 0 comments
Open
3 of 17 tasks
Labels
Area-JavaScript HTML CSS bug Something isn't working

Comments

@estalldecker
Copy link

Describe the bug

I'm not sure if it's a bug or is it by design but here is the issue I have.

Executing a javascript fetch in a javascript kernel works this way:

test = await fetch('https://jsonplaceholder.typicode.com/todos/1');
response = await test.json();
console.log(response);

but when I want to do a fetch to an auth'ed API, I guess it's captured by the underlying electron instance validating CORS?, because the fetch fails and it doesn't even appear in Fiddler:

testAPIcall = await fetch('<some api with auth and CORS>', {
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${accessToken}`
  } 
});

The error is this:

Image

the same api calls works ok with other kernels: c#, python, http.
Could it be possible to use a different fetch call that doesn't validate CORS for the js kernel?

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):
Version: 1.0.553001+f0ec3826954ea1ab829b435418328e4aa8db58e2
Library version: 1.0.0-beta.24530.1+f0ec3826954ea1ab829b435418328e4aa8db58e2
Build date: 2024-11-01T00:19:19.2878193Z

  • OS
    • Windows 11
    • Windows 10
    • macOS
    • Linux (Please specify distro)
    • iOS
    • Android
  • Browser
    • Chrome
    • Edge
    • Firefox
    • Safari
  • Frontend
    • Jupyter Notebook
    • Jupyter Lab
    • nteract
    • Visual Studio Code
    • Visual Studio Code Insiders
    • Visual Studio
    • Other (please specify)

Screenshots

If applicable, add screenshots to help explain your problem.

@jonsequitur jonsequitur added bug Something isn't working Area-JavaScript HTML CSS labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-JavaScript HTML CSS bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants