0

In the vscode extension I wrote, I want it to throw a fetch request when it presses a button in the webview panel. For this, I call a js file in the html code in the ts file I wrote. I wrote the fetch request that will be triggered when the button is pressed, into this js file. I'm facing a problem, the fetch request I sent has a header. When I send it as cors, the request goes with the header, but 401 is returned. But when I try it as no-cors, I don't get an error, but this time it doesn't send requests with Header. But the request I need to throw has to be this header so that the response is returned. I've searched a lot but couldn't find a solution. How can I send a get request to the api when this button is pressed? I can't find a solution as it is a specific error. Screenshot: No cors error: enter image description here The header doesn't come, but I don't get a cors error. cors error:enter image description here The header is coming, but I am getting a cors error.

I added the data I researched a lot about internet corsla as html. my meta codes <meta http-equiv="Content-Security-Policy" content="default-src 'self'; connect-src *; style-src ${webview.cspSource}; script-src 'nonce-${nonce}';"> In the js part, I added something to the header part, but it did not work. In the js part, I added something to the header part, but it did not work. My only expectation from the fetch request I sent is that when the button is pressed, it sends a get request to the API whose endpoint I gave.

VLAZ
  • 26,331
  • 9
  • 49
  • 67

0 Answers0