Commit 0efaf050 authored by Frank Bergmann's avatar Frank Bergmann

- Implemented CORS for new-system-incident

parent 5599f7a9
# /packages/intranet-forum/tcl/intranet-forum-procs.tcl
#
# Copyright (C) 2003 - 2009 ]project-open[
#
# All rights reserved. Please check
# http://www.project-open.com/license/ for details.
set prefix "/intranet-forum"
set url "${prefix}/*"
ns_register_proc OPTIONS ${url} im_forum_handle_options
......@@ -13,6 +13,34 @@ ad_library {
}
ad_proc -public im_forum_handle_options { uri method args } {
Dispatch request to the proper service contract implmentation
} {
ns_log Notice "im_forum_handle_options: uri=$uri, method=$method, args=$args"
eval im_forum_handle_options1
}
ad_proc -public im_forum_handle_options1 { } {
Handle AJAX CORS "pre-flight" request for headers.
This request comes with a HTTP "OPTIONS" verb.
} {
set url [ns_conn url]
ns_log Notice "im_forum_handle_options1: url=$url"
set header_vars [ns_conn headers]
set origin [ns_set get $header_vars "Origin"]
set request_headers [ns_set get $header_vars "Access-Control-Request-Headers"]
ns_set put [ns_conn outputheaders] "Access-Control-Allow-Methods" "GET, POST"
ns_set put [ns_conn outputheaders] "Access-Control-Allow-Headers" $request_headers
ns_set put [ns_conn outputheaders] "Access-Control-Allow-Origin" $origin
ns_return 200 "text/plain" ""
}
# ----------------------------------------------------------------------
# Select Boxes
# ----------------------------------------------------------------------
......
......@@ -38,6 +38,8 @@ ad_page_contract {
{ os_version ""}
}
# Allow for CORS requests to this page
ns_set cput [ns_conn outputheaders] "Access-Control-Allow-Origin" "*"
# -----------------------------------------------------------------
# Defaults & Security
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment