@@ -3,50 +3,29 @@ package cuhttp
33import (
44 "context"
55 "net/http"
6- "os"
76 "time"
87
98 "github.com/CAFxX/httpcompression"
109
1110 "github.com/filecoin-project/curio/deps/config"
1211)
1312
14- // AllowedCORSOrigins returns the public API CORS allowlist.
15- // DEV_CURIO_EXTERNAL_URL overrides the default https://{domainName} origin for local dev.
16- func AllowedCORSOrigins (domainName string ) []string {
17- if devURL := os .Getenv ("DEV_CURIO_EXTERNAL_URL" ); devURL != "" {
18- return []string {devURL }
19- }
20- return []string {"https://" + domainName }
21- }
22-
23- // CORS allows cross-origin API calls from AllowedCORSOrigins (e.g. market and PDP piece uploads).
13+ // CORS allows any origin on the public HTTP API (market, PDP, retrieval).
14+ // Admin UI CORS remains restricted via HTTP.CORSOrigins on the GUI port.
2415// Exposes the Location header so clients can read redirect targets after upload.
25- func CORS (allowedOrigins []string ) func (http.Handler ) http.Handler {
26- allowed := make (map [string ]struct {}, len (allowedOrigins ))
27- for _ , origin := range allowedOrigins {
28- allowed [origin ] = struct {}{}
29- }
30-
31- return func (next http.Handler ) http.Handler {
32- return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
33- origin := r .Header .Get ("Origin" )
34- if origin != "" {
35- if _ , ok := allowed [origin ]; ok {
36- w .Header ().Set ("Access-Control-Allow-Origin" , origin )
37- w .Header ().Set ("Access-Control-Allow-Methods" , "GET, HEAD, POST, PUT, DELETE, OPTIONS" )
38- w .Header ().Set ("Access-Control-Allow-Headers" , "Content-Type, Authorization, Accept, Accept-Encoding" )
39- w .Header ().Set ("Access-Control-Expose-Headers" , "Location" )
40- }
41- }
16+ func CORS (next http.Handler ) http.Handler {
17+ return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
18+ w .Header ().Set ("Access-Control-Allow-Origin" , "*" )
19+ w .Header ().Set ("Access-Control-Allow-Methods" , "GET, HEAD, POST, PUT, DELETE, OPTIONS" )
20+ w .Header ().Set ("Access-Control-Allow-Headers" , "Content-Type, Authorization, Accept, Accept-Encoding" )
21+ w .Header ().Set ("Access-Control-Expose-Headers" , "Location" )
4222
43- if r .Method == http .MethodOptions {
44- w .WriteHeader (http .StatusNoContent )
45- return
46- }
47- next .ServeHTTP (w , r )
48- })
49- }
23+ if r .Method == http .MethodOptions {
24+ w .WriteHeader (http .StatusNoContent )
25+ return
26+ }
27+ next .ServeHTTP (w , r )
28+ })
5029}
5130
5231// SecureHeaders adds standard browser security headers.
0 commit comments