CORS for webserver API to GET tiddler

I am trying to develop a chrome extension (zero experience) using webserver API to get tiddler status.

My purpose is to display an icon/link in the literature page if it is already managed by TW/refnotes through DOI. Is there any existing tools for this purpose?

My tiddlywiki is configured under node.js with TW 5.3.3.

However I cannot call fetch function for any GET request. Below is my minimum example of html/js scripts for demonstration purpose.

<html>
<body>
<script> 
async function gettiddler() {

   fetch("http://localhost:8080/recipes/default/tiddlers/test",{
   method: "GET",
   mode: 'cors',
   headers: {
            "Content-Type": "application/json",
             'Accept': 'application/json',
             "x-requested-with": "TiddlyWiki",
             "Access-Control-Allow-Origin":"*"
    }
   })
  .then((response) => response.json())
  .then((json) => console.log(json));
 
}

 gettiddler();
</script>
</body>
</html>

I have played with headers and mode parameters with different combinations and always get CORS error.

I believe the GET request in TW should not check CORS according to documentation.

Thanks for any suggestions.

The Access-Control-Allow-Origin is a header the server has to send to the client doing the GET. That tells the browser that it is OK to pass the response data to the JS doing the request.

Hi @Zheng_Bangyou the TW5 web server does not currently support sending CORS headers. Often configurations that require CORS headers also require a proxy server and so it is often easier to configure there. However, Iā€™d have no objection to adding basic native CORS support if there is demand.

Thanks @jeremyruston. I would be really useful if there is a native CORS support, especially for GET request.

As I mentioned above, now TW is my major manager for research literature. All information is stored into TW from webpage ā†’ Zotero ā†’ TW ā†’ LLM. Then I would like to use these information back to webpages, e.g. indicate whether I have managed it.