Csound Csound-dev Csound-tekno Search About

[Csnd] CORS errors in csound.js with midiplayer example

Date2020-12-04 15:16
FromRichard van Bemmelen
Subject[Csnd] CORS errors in csound.js with midiplayer example
AttachmentsScreenshot from 2020-12-04 16-13-56.png  
On Linux Mint with Chrome Version 87.0.4280.88,
I get CORS errors when loading the page.
This happens here:
    function CopyUrlToLocal(url, name, callback = null) {
        var xmlHttpRequest = new XMLHttpRequest();
        xmlHttpRequest.onload = function() {
            var data = new Uint8Array(xmlHttpRequest.response);
            csound.Csound.writeToFS(name, data);
            callback();
        };
        xmlHttpRequest.open("get", url, true);
        xmlHttpRequest.responseType = "arraybuffer";
        xmlHttpRequest.send(null);  <====error

I also include a screen shot


Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-12-04 15:24
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] CORS errors in csound.js with midiplayer example
Are you serving your pages from a local http server? I see a file protocol there, maybe that’s the problem. Perhaps some of the web people here might know more.
========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 4 Dec 2020, at 15:16, Richard van Bemmelen  wrote:
> 
> WARNINGThis email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> On Linux Mint with Chrome Version 87.0.4280.88,
> I get CORS errors when loading the page.
> This happens here:
>     function CopyUrlToLocal(url, name, callback = null) {
>         var xmlHttpRequest = new XMLHttpRequest();
>         xmlHttpRequest.onload = function() {
>             var data = new Uint8Array(xmlHttpRequest.response);
>             csound.Csound.writeToFS(name, data);
>             callback();
>         };
>         xmlHttpRequest.open("get", url, true);
>         xmlHttpRequest.responseType = "arraybuffer";
>         xmlHttpRequest.send(null);  <====error 
> 
> I also include a screen shot
> 
> 
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> 


Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-12-04 15:24
FromSteven Yi
SubjectRe: [Csnd] CORS errors in csound.js with midiplayer example
Hi Richard,

This is normal for web development. You'll need load the site through
a webserver rather than opening the html file directly. There's a note
about this in the README.md:

"You will also need a http-server to serve the WebAudio Csound source files."

Easiest solution I use is editing in VS Code and using the Live Server
plugin which allows you to click a file and "Open with Live Server".
You can also use Python's built-in server (I can't recall the command
for Python3 but it should be easy to find online) or install one with
npm (i.e., http-server)

Steven

On Fri, Dec 4, 2020 at 10:16 AM Richard van Bemmelen
 wrote:
>
> On Linux Mint with Chrome Version 87.0.4280.88,
> I get CORS errors when loading the page.
> This happens here:
>     function CopyUrlToLocal(url, name, callback = null) {
>         var xmlHttpRequest = new XMLHttpRequest();
>         xmlHttpRequest.onload = function() {
>             var data = new Uint8Array(xmlHttpRequest.response);
>             csound.Csound.writeToFS(name, data);
>             callback();
>         };
>         xmlHttpRequest.open("get", url, true);
>         xmlHttpRequest.responseType = "arraybuffer";
>         xmlHttpRequest.send(null);  <====error
>
> I also include a screen shot
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-12-04 15:51
FromRory Walsh
SubjectRe: [Csnd] CORS errors in csound.js with midiplayer example
You can also use an online JS editor and bypass the local server stuf. Repl.it is pretty nice, just upload your source there and away you go. CodePen, jsFiddle, the p5Js editor, etc, they can all be used to run and test CsoundWeb.  

On Fri, 4 Dec 2020 at 15:24, Steven Yi <stevenyi@gmail.com> wrote:
Hi Richard,

This is normal for web development. You'll need load the site through
a webserver rather than opening the html file directly. There's a note
about this in the README.md:

"You will also need a http-server to serve the WebAudio Csound source files."

Easiest solution I use is editing in VS Code and using the Live Server
plugin which allows you to click a file and "Open with Live Server".
You can also use Python's built-in server (I can't recall the command
for Python3 but it should be easy to find online) or install one with
npm (i.e., http-server)

Steven

On Fri, Dec 4, 2020 at 10:16 AM Richard van Bemmelen
<zappfinger@gmail.com> wrote:
>
> On Linux Mint with Chrome Version 87.0.4280.88,
> I get CORS errors when loading the page.
> This happens here:
>     function CopyUrlToLocal(url, name, callback = null) {
>         var xmlHttpRequest = new XMLHttpRequest();
>         xmlHttpRequest.onload = function() {
>             var data = new Uint8Array(xmlHttpRequest.response);
>             csound.Csound.writeToFS(name, data);
>             callback();
>         };
>         xmlHttpRequest.open("get", url, true);
>         xmlHttpRequest.responseType = "arraybuffer";
>         xmlHttpRequest.send(null);  <====error
>
> I also include a screen shot
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2020-12-04 16:02
FromRichard
SubjectRe: [Csnd] [EXTERNAL] [Csnd] CORS errors in csound.js with midiplayer example
I did start the supplied Python web server first.

It works now, but only in Firefox. Chrome  crashes badly...

On 04/12/2020 16:24, Victor Lazzarini wrote:
> Are you serving your pages from a local http server? I see a file protocol there, maybe that’s the problem. Perhaps some of the web people here might know more.
> ========================
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
>
>> On 4 Dec 2020, at 15:16, Richard van Bemmelen  wrote:
>>
>> WARNINGThis email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>> On Linux Mint with Chrome Version 87.0.4280.88,
>> I get CORS errors when loading the page.
>> This happens here:
>>      function CopyUrlToLocal(url, name, callback = null) {
>>          var xmlHttpRequest = new XMLHttpRequest();
>>          xmlHttpRequest.onload = function() {
>>              var data = new Uint8Array(xmlHttpRequest.response);
>>              csound.Csound.writeToFS(name, data);
>>              callback();
>>          };
>>          xmlHttpRequest.open("get", url, true);
>>          xmlHttpRequest.responseType = "arraybuffer";
>>          xmlHttpRequest.send(null);  <====error
>>
>> I also include a screen shot
>>
>>
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
>> 
>
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>          https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-12-04 16:24
FromRichard
SubjectRe: [Csnd] CORS errors in csound.js with midiplayer example
Of course Steven, how could I forget.

On 04/12/2020 16:24, Steven Yi wrote:
> Hi Richard,
>
> This is normal for web development. You'll need load the site through
> a webserver rather than opening the html file directly. There's a note
> about this in the README.md:
>
> "You will also need a http-server to serve the WebAudio Csound source files."
>
> Easiest solution I use is editing in VS Code and using the Live Server
> plugin which allows you to click a file and "Open with Live Server".
> You can also use Python's built-in server (I can't recall the command
> for Python3 but it should be easy to find online) or install one with
> npm (i.e., http-server)
>
> Steven
>
> On Fri, Dec 4, 2020 at 10:16 AM Richard van Bemmelen
>  wrote:
>> On Linux Mint with Chrome Version 87.0.4280.88,
>> I get CORS errors when loading the page.
>> This happens here:
>>      function CopyUrlToLocal(url, name, callback = null) {
>>          var xmlHttpRequest = new XMLHttpRequest();
>>          xmlHttpRequest.onload = function() {
>>              var data = new Uint8Array(xmlHttpRequest.response);
>>              csound.Csound.writeToFS(name, data);
>>              callback();
>>          };
>>          xmlHttpRequest.open("get", url, true);
>>          xmlHttpRequest.responseType = "arraybuffer";
>>          xmlHttpRequest.send(null);  <====error
>>
>> I also include a screen shot
>>
>>
>> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>          https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2020-12-04 16:25
FromRichard
SubjectRe: [Csnd] CORS errors in csound.js with midiplayer example

Thanks, good to know!

On 04/12/2020 16:51, Rory Walsh wrote:
You can also use an online JS editor and bypass the local server stuf. Repl.it is pretty nice, just upload your source there and away you go. CodePen, jsFiddle, the p5Js editor, etc, they can all be used to run and test CsoundWeb.  

On Fri, 4 Dec 2020 at 15:24, Steven Yi <stevenyi@gmail.com> wrote:
Hi Richard,

This is normal for web development. You'll need load the site through
a webserver rather than opening the html file directly. There's a note
about this in the README.md:

"You will also need a http-server to serve the WebAudio Csound source files."

Easiest solution I use is editing in VS Code and using the Live Server
plugin which allows you to click a file and "Open with Live Server".
You can also use Python's built-in server (I can't recall the command
for Python3 but it should be easy to find online) or install one with
npm (i.e., http-server)

Steven

On Fri, Dec 4, 2020 at 10:16 AM Richard van Bemmelen
<zappfinger@gmail.com> wrote:
>
> On Linux Mint with Chrome Version 87.0.4280.88,
> I get CORS errors when loading the page.
> This happens here:
>     function CopyUrlToLocal(url, name, callback = null) {
>         var xmlHttpRequest = new XMLHttpRequest();
>         xmlHttpRequest.onload = function() {
>             var data = new Uint8Array(xmlHttpRequest.response);
>             csound.Csound.writeToFS(name, data);
>             callback();
>         };
>         xmlHttpRequest.open("get", url, true);
>         xmlHttpRequest.responseType = "arraybuffer";
>         xmlHttpRequest.send(null);  <====error
>
> I also include a screen shot
>
>
> Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here