{"id":49,"date":"2022-03-22T01:02:48","date_gmt":"2022-03-21T16:02:48","guid":{"rendered":"https:\/\/pvision.jp\/apps\/?p=49"},"modified":"2026-03-25T22:09:42","modified_gmt":"2026-03-25T13:09:42","slug":"cors-support-for-redsync","status":"publish","type":"post","link":"https:\/\/pvision.jp\/apps\/2022\/03\/22\/cors-support-for-redsync\/","title":{"rendered":"CORS Support for RedSync"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Requirement<\/h2>\n\n\n\n<p>RedSync may require CORS support depending on configuration. In such a case, there are three options as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use rack-cors<\/li>\n\n\n\n<li>Handle by Web Server<\/li>\n\n\n\n<li>Use Reverse Proxy<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Use rack-cors<\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/rack\/rack#label-Rack-2C+a+modular+Ruby+webserver+interface\" target=\"_blank\" rel=\"noreferrer noopener\">Rack<\/a> provides an interface between a Web server and a Ruby application. The <a href=\"https:\/\/github.com\/cyu\/rack-cors#rack-cors-middleware-\" target=\"_blank\" rel=\"noreferrer noopener\">rack-cors<\/a> is a Ruby module based on Rack and supports CORS.<\/p>\n\n\n\n<p>The rack-cors requires the Web server for Redmine to conform to the Rack specification. The list of supported Web servers is <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/rack\/rack#label-Supported+web+servers\" target=\"_blank\">here<\/a>.<\/p>\n\n\n\n<p>Please refer to <a href=\"https:\/\/github.com\/cyu\/rack-cors#rack-cors-middleware-\" target=\"_blank\" rel=\"noreferrer noopener\">this article<\/a> for the installation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Handle by Web Server<\/h2>\n\n\n\n<p>A web server can support CORS by adding headers and rewriting the status code in an HTTP response.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Apache<\/h3>\n\n\n\n<p>In the case of the Apache server, you can add the following definitions to the httpd.conf file.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-html\" data-file=\"httpd.conf\" data-lang=\"HTML\"><code>&lt;Location \/&gt;\n  &lt;IfModule mod_headers.c&gt;\n    Header always set Access-Control-Allow-Origin &quot;*&quot;\n    Header always set Access-Control-Allow-Methods &quot;POST, GET, OPTIONS, DELETE, PUT, PATCH&quot;\n    Header always set Access-Control-Max-Age &quot;7200&quot;\n    Header always set Access-Control-Allow-Headers &quot;Content-Type, x-redmine-api-key&quot;\n  &lt;\/IfModule&gt;\n\n  &lt;IfModule mod_rewrite.c&gt;\n    RewriteEngine On\n    RewriteCond %{REQUEST_METHOD} OPTIONS\n    RewriteRule ^(.*)$ $1 [R=200,L]\n  &lt;\/IfModule&gt;\n&lt;\/Location&gt;<\/code><\/pre><\/div>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Apache2 on Ubuntu\/Debian<br>\/etc\/apache2\/apache2.conf<br>Or you can create a new conf file in the <code>\/etc\/apache2\/conf-available<\/code> directory, then enable it by the <code>a2enconf<\/code> command.<\/li>\n\n\n\n<li>Bitnami (on Debian)<br>\/opt\/bitnami\/apache\/conf\/httpd.conf<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Use Reverse-Proxy<\/h2>\n\n\n\n<p>If you are using Redmine on SaaS or the IT department is managing the Redmine server, it may be difficult to change its configuration to support CORS. In such a case, the Reverse-Proxy server may be an option to support CORS.<\/p>\n\n\n\n<p>If you are on the Pro plan, you can use RedSync Proxy to access the Redmine server without CORS support.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>RedSync may require CORS support depending on configuration. Check how you can support CORS in your server.<\/p>\n","protected":false},"author":1,"featured_media":187,"comment_status":"closed","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"wf_post_folders":[12],"class_list":["post-49","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-redsync"],"_links":{"self":[{"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/posts\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/comments?post=49"}],"version-history":[{"count":30,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/posts\/49\/revisions"}],"predecessor-version":[{"id":5773,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/posts\/49\/revisions\/5773"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/media\/187"}],"wp:attachment":[{"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/media?parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/categories?post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/tags?post=49"},{"taxonomy":"wf_post_folders","embeddable":true,"href":"https:\/\/pvision.jp\/apps\/wp-json\/wp\/v2\/wf_post_folders?post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}