rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: kabutzal on December 06, 2015, 04:24:34 PM

Title: CORS header - can't get this to work
Post by: kabutzal on December 06, 2015, 04:24:34 PM
I need to have all files from HFS served with CORS (Access-Control-Allow-Origin header).
Unfortunately, I don't understand much about HFS macros and templates.

I tried implementing the solution given here with no luck:
http://www.rejetto.com/forum/html-templates/cors-header-and-simple-template-for-javascript-driven-access/

Can someone please explain in detail how to do this?

Thanks
Title: Re: CORS header - can't get this to work
Post by: bmartino1 on December 06, 2015, 05:08:53 PM
okay, that one of mayny post redirefts

so yo have to have a javaspcipot, or some html / macor coding with HFS to send and receve dat via the headder....

so the post that you posted goes over covering a few issue (assuming you already have the JavaScript code to download and upload! (that was never shared int eh post!

what was shared was the issue / fix for that person:

http://www.rejetto.com/forum/html-templates/cors-header-and-simple-template-for-javascript-driven-access/msg1058937/#msg1058937
Code: [Select]
Add {.add header | Access-Control-Allow-Origin: * .} to template works for templateswhich orginaly is not in HFS.... os it was added to HFS....

the post later went on to go to a template that had those requests " XMLHttpRequest(GET ... ). / XMLHttpRequest(PUT ...)
http://www.rejetto.com/forum/italiano/template-vista-con-chat-e-video-player-italiano-vers-1-8-new/?action=dlattach;attach=7846

which has how the code can work.....

Now that rases the question??? - what did you " I tried implementing" ?
What do you need help with?

what are you trying to do?...
Title: Re: CORS header - can't get this to work
Post by: kabutzal on December 06, 2015, 06:49:02 PM
I have a few files sitting in HFS's virtual file system.
When a browser tries to access/download these files, I need HFS to include the CORS headers in the response.

Here are the instructions for various server types:
http://enable-cors.org/server.html

HFS is not there.

Is this possible?
Title: Re: CORS header - can't get this to work
Post by: bmartino1 on December 07, 2015, 04:52:34 PM
form the forum post and the link you have sent me, to my understanding, it is possible....

http://www.html5rocks.com/en/tutorials/cors/

You need to add this to hfs header!...

so right click properties "/" the house in HFS
Different template tab

add this line:
Code: [Select]
{.add header | Access-Control-Allow-Origin: * .}
derived form the other forum post adn your site:

http://enable-cors.org/server_php.html
http://enable-cors.org/server_perl.html
Title: Re: CORS header - can't get this to work
Post by: kabutzal on January 04, 2016, 10:44:08 AM
Thank you so much!
Title: Re: CORS header - can't get this to work
Post by: rejetto on January 06, 2016, 02:34:02 PM
i would try events instead changing the template
Menu > other options > edit event scripts
then put this
Code: [Select]
[download]
{.add header | Access-Control-Allow-Origin: * .}
Title: Re: CORS header - can't get this to work
Post by: surikat on February 28, 2019, 12:57:18 PM
i would try events instead changing the template
Menu > other options > edit event scripts
then put this
Code: [Select]
[download]
{.add header | Access-Control-Allow-Origin: * .}

It does not work for me. Requests to save a text file .txt Where to save it?
Title: Re: CORS header - can't get this to work
Post by: surikat on February 28, 2019, 01:01:11 PM
form the forum post and the link you have sent me, to my understanding, it is possible....

http://www.html5rocks.com/en/tutorials/cors/

You need to add this to hfs header!...

so right click properties "/" the house in HFS
Different template tab

add this line:
Code: [Select]
{.add header | Access-Control-Allow-Origin: * .}
derived form the other forum post adn your site:

http://enable-cors.org/server_php.html
http://enable-cors.org/server_perl.html

Also the error repeats. Maybe because I take the file through the port and I need to specify the address of the type:

Code: [Select]
{.add header | Access-Control-Allow-Origin: site.com:port .}   ?
Title: Re: CORS header - can't get this to work
Post by: bmartino1 on March 01, 2019, 01:33:42 PM
i would try events instead changing the template
Menu > other options > edit event scripts
then put this
Code: [Select]
[download]
{.add header | Access-Control-Allow-Origin: * .}

More of a question for rejeto. (As I wouldn't know how to tell the full coros hand shake and see it. I'd wore shark the packet to see the header.

As long as you followed rejeto instructions this should.be working g on the stable build