Customize access-control-allow-origin headers in order to set specific origin domains
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
Direzione di ricerca
Inizia tracciando come viene analizzata l’opzione --cors e dove viene impostato l’header di risposta access-control-allow-origin. Esamina il comportamento CORS esistente e la relativa documentazione prima di decidere come rappresentare le origini configurabili. Il lavoro è completato quando consente domini specifici o * mantenendo il comportamento corretto delle richieste con credenziali.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What's the problem this feature will solve?
Currently, with --cors enabled access-control-allow-origin hard coded to *. If http-server is behind features that require authentication (client SSL certs in my case), the fetch spec requires browsers to validate that the requesting server be set as an allowed origin. So when server1 makes a request to server2 it fails because of the wildcard. This is the intended behavior as designed. Firefox currently (correctly) follows the fetch spec but, Chrome and Edge do not. At some point, chrome and edge 'should' eventually be fixed.
Chrome and Edge still send certs unprompted when executing the fetch command, but when fetch is set to {credentials:"include"} in server1 requesting information from server2 you now get this error:
Access to fetch at 'https://server2.tld' from origin 'https://server1.tld' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
Describe the solution you'd like
Requesting the ability to customize access-control-allow-origin headers in order to pass specific domains or set * manually.
This will allow http-server to be used correctly with authentication when a fetch is set to { credentials:"include" } .
Alternative Solutions
When requesting server does not have fetch is set to { credentials:"include" }
- Firefox: in about:config set
network.cors_preflight.allow_client_certto true. Otherwise browser fails preflight because certs are not passed. - Chrome: in chrome://flags set
Omit TLS client certificates if credential mode disallowsto disabled. This is also the default behavior, chrome automatically sends credentials, this is against the spec. - Edge: no changes, flags are not available for this setting (default behavior, edge automatically sends credentials, this is against the spec.
When fetch is set to { credentials:"include" } on server1
Fails on all browsers
Access to fetch at 'https://server2.tld' from origin 'https://server1.tld' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
Alternate hack
Modify http-server source locally to hard code for my specific use-case, replace access-control-allow-origin = '*' and hard code it to access-control-allow-origin = 'https://server1.tld so it works for me. then enable --cors, start http-server.
Additional context
I'm sure there are other use-cases for setting access-control-allow-origin to custom domains, but for the authentication issue with client SSL certs, it's a must have.
I am aware that solution #760 to issue #729 can potentially fix my problem, but automatically mirroring the origin server will allow any origin to pass credentials, which is not very safe. This fix should only be used for testing and not production.
- Lingua principale
- JavaScript
- Stelle
- 14.2k
- Fork
- 1.6k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di http-party/http-server
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
http-party/http-server#982 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
http-party/http-server#977 · 2 reazioni ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 8/100
http-party/http-server#980 · 2 commenti ·
-
New chetAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
http-party/http-server#976 ·
-
Dreams local boyAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
http-party/http-server#975 ·
Tutte le issue di http-party/http-server
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
microsoft/TypeScript#65370 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue priority: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
TMHSDigital/Free-Game-Dev-Assets#272 ·
I maintainer di solito rispondono entro 1 giorno
-
metrics priority: medium
Difficoltà 1/5 1-3 ore Idoneità per principianti 86/100
LearningCircuit/local-deep-research#8336 ·
I maintainer di solito rispondono entro 1 giorno
-
ace bug yaml
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
svelte: whitespace-only edit leaves an empty todo, edits not trimmed, filter not restored on reloadAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100