Thanks Joshua,

I did figure this out. I had to add some headers to the server.js and put 
handler  files.

I'm definitely not an expert in the area, but i believe it is safe. The 
Javascript code is running from a bookmarklet in my browser.  The 
bookmarklet just sends the current web page title and url to the node 
server using the WebServer API, which creates a tiddler from the data. I 
think I wanted to do it more out of curiosity than any useful purpose. 

javascript: (
  function () {
    var data = JSON.stringify({ "tags": "Link", "url": window.location.href 
});
    var xhr = new XMLHttpRequest();
    xhr.open('PUT', 'http://127.0.0.1:8080/recipes/default/tiddlers/' + 
document.title);
    xhr.onreadystatechange = function () {
      if (xhr.readyState === 4) {
        console.log('xhr.status: ' + xhr.status);
        console.log('xhr.responseText: ' + xhr.responseText);
      }
    };
    xhr.send(data);
  })();

On Saturday, October 10, 2020 at 11:18:36 PM UTC-4 joshua....@gmail.com 
wrote:

>
> CORS errors are a problem when the javascript you are running is being run 
> from within the Browser, but is trying to access a resource that is not on 
> the "same domain" as the document you are viewing.
>
> As long as you 100% make sure that your code is running on the _Server_ 
> (node.js), it can then make any modifications to the Wiki files you need. 
> This will then be picked up the next time the browser syncs with the server.
>
> Best,
> Joshua Fontany
> On Saturday, October 10, 2020 at 1:41:57 PM UTC-7 amreus wrote:
>
>> Is it possible to allow Cross Origin Resource Sharing when running a node 
>> wiki locally?
>>
>> I'm starting the server using the command: tiddlywiki.js <dir> --listen
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a54f58f2-36e5-4dde-8d74-96acf179122fn%40googlegroups.com.

Reply via email to