Author Topic: CORS header - can't get this to work  (Read 1980 times)

0 Members and 1 Guest are viewing this topic.

Offline kabutzal

  • Occasional poster
  • *
  • Posts: 3
    • View Profile
CORS header - can't get this to work
« 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

Offline bmartino1

  • Tireless poster
  • ****
  • Posts: 861
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
Re: CORS header - can't get this to work
« Reply #1 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?...
I'm only trying to help i mean no offense.
thank you for your time and patience,
Bmartino1

Offline kabutzal

  • Occasional poster
  • *
  • Posts: 3
    • View Profile
Re: CORS header - can't get this to work
« Reply #2 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?

Offline bmartino1

  • Tireless poster
  • ****
  • Posts: 861
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
Re: CORS header - can't get this to work
« Reply #3 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
I'm only trying to help i mean no offense.
thank you for your time and patience,
Bmartino1

Offline kabutzal

  • Occasional poster
  • *
  • Posts: 3
    • View Profile
Re: CORS header - can't get this to work
« Reply #4 on: January 04, 2016, 10:44:08 AM »
Thank you so much!

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12949
    • View Profile
Re: CORS header - can't get this to work
« Reply #5 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: * .}

Follow members gave a thank to your post:


Offline surikat

  • Occasional poster
  • *
  • Posts: 54
    • View Profile
Re: CORS header - can't get this to work
« Reply #6 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?

Offline surikat

  • Occasional poster
  • *
  • Posts: 54
    • View Profile
Re: CORS header - can't get this to work
« Reply #7 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 .}   ?

Offline bmartino1

  • Tireless poster
  • ****
  • Posts: 861
  • I'm only trying to help i mean no offense.
    • View Profile
    • My HFS Google Drive Shared Link
Re: CORS header - can't get this to work
« Reply #8 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
I'm only trying to help i mean no offense.
thank you for your time and patience,
Bmartino1