Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
digibib
minotaur
Commits
cd57883b
Commit
cd57883b
authored
Aug 21, 2018
by
Benjamin Rokseth
Browse files
Add Cors
parent
ac8915a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
minotaur.go
View file @
cd57883b
...
...
@@ -17,6 +17,7 @@ import (
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/cors"
minio
"github.com/minio/minio-go"
//"github.com/h2non/bimg" // TODO: image processing -- sudo apt install libvips-tools
)
...
...
@@ -47,6 +48,16 @@ func (s *server) ListenAndServe(addr string) error {
func
(
s
*
server
)
setupRouter
()
*
chi
.
Mux
{
r
:=
chi
.
NewRouter
()
cors
:=
cors
.
New
(
cors
.
Options
{
AllowedOrigins
:
[]
string
{
"*"
},
// AllowOriginFunc: func(r *http.Request, origin string) bool { return true },
AllowedMethods
:
[]
string
{
"GET"
,
"POST"
,
"PUT"
,
"DELETE"
,
"OPTIONS"
},
AllowedHeaders
:
[]
string
{
"Accept"
,
"Authorization"
,
"Content-Type"
,
"X-CSRF-Token"
},
ExposedHeaders
:
[]
string
{
"Link"
,
"Location"
},
AllowCredentials
:
true
,
MaxAge
:
300
,
// Maximum value not ignored by any of major browsers
})
r
.
Use
(
cors
.
Handler
)
r
.
Use
(
middleware
.
Logger
,
// TODO remove when going live - too much noise
middleware
.
DefaultCompress
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment