mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
fix: CORS on assets api (#3659)
This commit is contained in:
@@ -40,9 +40,9 @@ const (
|
||||
|
||||
type key int
|
||||
|
||||
var (
|
||||
httpHeaders key
|
||||
remoteAddr key
|
||||
const (
|
||||
httpHeaders key = iota
|
||||
remoteAddr
|
||||
)
|
||||
|
||||
func CopyHeadersToContext(h http.Handler) http.Handler {
|
||||
@@ -59,6 +59,14 @@ func HeadersFromCtx(ctx context.Context) (http.Header, bool) {
|
||||
return headers, ok
|
||||
}
|
||||
|
||||
func OriginFromCtx(ctx context.Context) string {
|
||||
headers, ok := ctx.Value(httpHeaders).(http.Header)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return headers.Get(Origin)
|
||||
}
|
||||
|
||||
func RemoteIPFromCtx(ctx context.Context) string {
|
||||
ctxHeaders, ok := HeadersFromCtx(ctx)
|
||||
if !ok {
|
||||
|
Reference in New Issue
Block a user