horse-cors icon indicating copy to clipboard operation
horse-cors copied to clipboard

Proposal for multi-domain usage for allowed-origin

Open Dzyszla opened this issue 1 year ago • 0 comments

Hi,

I have some sugesstion for modyfication. Browswers don't allow multiple domains, so if I want do this, I must to make this:

procedure(Req: THorseRequest; Res: THorseResponse; Next: {$IF DEFINED(FPC)}TNextProc{$ELSE}  TProc {$ENDIF})
var
	sl: TArray<String>;
	Origin: String;
begin
	sl := MyAllowOrigin.Split([',', ';']);

	Origin := Req.Headers['Origin'];
	if not MatchText(Origin, sl) then
		Origin := 'null';

	HorseCORS()
		.AllowedOrigin(Origin);

	CORS(Req, Res, Next);
end;

Maybe can some similar put into horse-cors?

Dzyszla avatar Aug 06 '24 06:08 Dzyszla