Skip to content

Commit

Permalink
Handle CORS Preflight Requests in Lighttpd
Browse files Browse the repository at this point in the history
  • Loading branch information
Rub21 committed Sep 14, 2023
1 parent 5f924b8 commit bf1e8ca
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions images/web/config/lighttpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ server.port = 81
server.reject-expect-100-with-417 = "disable"

# selecting modules
server.modules = ( "mod_access", "mod_rewrite", "mod_fastcgi", "mod_proxy", "mod_alias", "mod_setenv" ) # Added mod_setenv

# Add CORS headers to all responses
setenv.add-response-header = ( "Access-Control-Allow-Origin" => "*",
"Access-Control-Allow-Methods" => "GET, POST, PUT, OPTIONS",
"Access-Control-Allow-Headers" => "origin, x-requested-with, content-type" )
server.modules = ( "mod_access", "mod_rewrite", "mod_fastcgi", "mod_proxy", "mod_alias" )

# handling unknown routes
server.error-handler-404 = "/dispatch.map"
Expand All @@ -29,6 +24,17 @@ mimetype.assign = (
".png" => "image/png"
)

# Handle CORS Preflight Requests
$HTTP["request-method"] == "OPTIONS" {
setenv.add-response-header = (
"Access-Control-Allow-Origin" => "*",
"Access-Control-Allow-Methods" => "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers" => "origin, x-requested-with, content-type",
"Access-Control-Allow-Credentials" => "true",
"Access-Control-Max-Age" => "86400"
)
}

#debug.log-request-handling = "enable"

$HTTP["request-method"] == "GET" {
Expand Down

0 comments on commit bf1e8ca

Please sign in to comment.