#1 2022-03-30 03:41:47

wangming
Member
Registered: 2016-07-17
Posts: 24

Cross-domain access problem, the browser issues a pre-visit OPTIONS

The background uses version 1.18, the post method, the front-end uses the page developed by vue, and the vue page is opened through the browser. Due to cross-domain, the browser will issue a pre-visit OPTIONS,
The background is set up like this:
  if Ctxt.Method = 'OPTIONS' then
   begin
     try
       Ctxt.OutCustomHeaders:='Access-Control-Allow-Origin:*'; //Allow cross-domain access
       result := 200;
     finally
     end;
   end
But on the browser side, this prompt keeps appearing: Access to XMLHttpRequest at 'http://localhost:8689/api/exampi/getexampersonbasicInfo/1.0' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

Please, how can I set the background to solve this problem?

Offline

#2 2022-03-30 06:19:54

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,661
Website

Re: Cross-domain access problem, the browser issues a pre-visit OPTIONS

The CORS options are already handled at TSQLHttpServer level.

Please see AccessControlAllowOrigin and AccessControlAllowCredential fields.

Offline

Board footer

Powered by FluxBB