Fix a bug where searching in web app using iOS causes page to reload (#645)

* Fix a bug where searching in web app using iOS causes page to reload

* Add cors handler in prod
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2025-06-07 10:55:07 -04:00
1 parent 06326d084e
commit 58e2b48409
4 files changed
+84 -67

No files matched your search

@@ -40,6 +40,8 @@ function SetupRoutes(server as object)
#if DEBUG
'CORS is mostly for developing the web app
server.UseRouter(new Http.CorsMiddleware())
#else
server.UseRouter(new Http.CorsMiddleware(""))
#end if
if server.settings.WebSocketsEnabled
server.UseRouter(new Http.WebSocketMiddleware())
@@ -20,9 +20,17 @@ namespace Http
request = context.request
response = context.response
response.headers["Access-Control-Allow-Origin"] = m.origin
response.headers["Access-Control-Allow-Headers"] = m.headers
response.headers["Access-Control-Allow-Methods"] = m.methods
if not StringUtils.IsNullOrEmpty(m.origin)
response.headers["Access-Control-Allow-Origin"] = m.origin
end if
if not StringUtils.IsNullOrEmpty(m.headers)
response.headers["Access-Control-Allow-Headers"] = m.headers
end if
if not StringUtils.IsNullOrEmpty(m.methods)
response.headers["Access-Control-Allow-Methods"] = m.methods
end if
if request.method = "OPTIONS"
response.header_only = true