Add content-type header for generated config.js
This commit is contained in:
@@ -123,6 +123,11 @@ func serveIndex(opt options.HttpServerOpt, indexHTML []byte, serve http.Handler)
|
||||
|
||||
func serveConfig(r chi.Router, config webappConfig) {
|
||||
r.Get(options.CleanBase(config.appUrl, "config.js"), func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Assure the content-type
|
||||
// The presence of the X-Content-Type-Options: nosniff header breaks web applications
|
||||
w.Header().Add("Content-Type", "text/javascript")
|
||||
|
||||
const line = "window.%s = '%s';\n"
|
||||
_, _ = fmt.Fprintf(w, line, "CortezaAPI", config.apiBaseUrl)
|
||||
_, _ = fmt.Fprintf(w, line, "CortezaAuth", config.authBaseUrl)
|
||||
|
||||
Reference in New Issue
Block a user