Home > Back-end >  Delphi xe10 indy httpserver webservice how to support remote JS cross-domain calls
Delphi xe10 indy httpserver webservice how to support remote JS cross-domain calls

Time:09-15

Add on the HTTP response Access - Control - Allow - Origin * this know

How to write the httpserver response header????

CodePudding user response:

Alternative solution to compile Apache or IIS modules

CodePudding user response:

Procedure TServer. IdHTTPServerCommandGet (AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
Var
CContext: TClientContext;
T: TSomeThread;
The begin
//Beep;
//Sleep (10000);

T:=TSomeThread. Create (true);
T.F reeOnTerminate:=true;
T.S tart.

AResponseInfo. ResponseNo:=200;
AResponseInfo. CacheControl:='no - cache;
AResponseInfo. CustomHeaders. Add (' Access - Control - Allow - Origin: * ');
AResponseInfo. ContentText:='ok';
AResponseInfo. ResponseNo:=200;
AResponseInfo. WriteContent;


The end;
  • Related