简体   繁体   中英

“Test failed: Error: Origin is not allowed by Access-Control-Allow-Origin” in Composer - Appgyver

I am creating an App in Appgyver Composer. I have a PHP file which perfect and gives appropriate response when triggered. I tried making this a service by putting appropriate credentials. However, the test returned the following error :

"Test failed: Error: Origin is not allowed by Access-Control-Allow-Origin"

Any idea how I can set Access Control Allow Login to "*" in Composer? The tag already exists in the php file on my server.

I have also added "Access-Control-Allow-Origin" in header to "*", hoping that might do the trick.

Anyone did anything similar?

In your php script, set Access-Control-Allow-Origin to the value of the calling domain (the value of the Origin header). If you don't care who has access, you can just send back the Origin header from the request as so:

$origin = $_SERVER['HTTP_ORIGIN'] !== null ? $_SERVER['HTTP_ORIGIN'] : '*';
header('Access-Control-Allow-Origin: '.$origin);

HTTP access control (CORS)

when responding to a credentialed request, server must specify a domain, and cannot use wild carding.

I used a workaround. The POST method on the server was creating the issue, apparently. I used GET method and it started working perfectly. You might wanna consider that later.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM