mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-03-30 20:45:38 +00:00
Enable CORS by default, which is necessary for AJAX resolver to run
This commit is contained in:
@@ -108,9 +108,18 @@ func (s *Server) Start() error {
|
||||
func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
|
||||
w.Header().Set("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS, POST")
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
w.Header().Set("Access-Control-Max-Age", "3600")
|
||||
w.Header().Set("Server", USER_AGENT)
|
||||
w.Header().Set("X-Powered-By", USER_AGENT)
|
||||
|
||||
if r.Method == "OPTIONS" {
|
||||
w.Header().Set("Content-Length", "0")
|
||||
return
|
||||
}
|
||||
|
||||
if r.Form == nil {
|
||||
const maxMemory = 32 << 20 // 32 MB
|
||||
r.ParseMultipartForm(maxMemory)
|
||||
|
||||
Reference in New Issue
Block a user