-
Notifications
You must be signed in to change notification settings - Fork 99
/
server_caddy.html
37 lines (34 loc) · 1.13 KB
/
server_caddy.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
layout: default
title: enable cross-origin resource sharing on caddyserver
---
<div class="container">
<section>
<h1>CORS on Caddyserver version 1</h1>
<p>
To add the CORS authorization to the header using Caddy 1, simply add the following line inside your caddyfile:
</p>
<pre class="code">cors</pre>
<p>
This will allow <b>all</b> resources to be accessed from <b>every</b> domain.
</p>
<p>
You can also be more specific, i.e. allow specific resources to specific domains:
</p>
<pre class="code">cors /foo http://mysite.com http://anothertrustedsite.com</pre>
<p>
There are many more options you can use, here is a full example, as shown in the
<a href="https://caddyserver.com/docs/cors" target="_blank">caddyserver docs</a>:
</p>
<pre class="code">
cors / {
origin http://allowedSite.com
origin http://anotherSite.org https://anotherSite.org
methods POST,PUT
allow_credentials false
max_age 3600
allowed_headers X-Custom-Header,X-Foobar
exposed_headers X-Something-Special,SomethingElse
}</pre>
</section>
</div>