Forum OpenACS Development: Page's Document header

Posted by Iuri Sampaio on
What would be similar response headers to what exists in PHP world

1. header('Access-Control-Allow-Origin: *');
2. header('Content-Type: application/json');

Reading OACS documentation, as well as examples of code, I've written the following correspondent to #2

doc_return 200 "application/json" $json

But, failed to find a solution to #1. I did even tryed to use the intuition as in:

doc_return 200 {"access-control-allow-origin:*; application/json;"} $json

However, in the case of Access-Control-Allow-Origin, things turned to be trickier as already expected.

After applying a few possibilities:
i. as the second argument of doc_return,
ii. as a new argument;
iii. forcing the script by adding directly in the HTML header of the page;

In all cases, JSON format seems to break.

What would be the proper way to implement header('Access-Control-Allow-Origin: *')?

Best wishes

2: Re: Page's Document header (response to 1)
Posted by Iuri Sampaio on
Finally, I got it working.

doc_return 200 "application/json; access-control-allow-origin:*;" $json

Furthermore, I found good references for CORS response headers. See bellow:


Nevertheless, I'd like to understand how CORS is applied in OACS and NS.

Any good documentation is welcome!

Best wishes,