question

starkgaminginc avatar image
starkgaminginc asked

UE4 & CORS w/ PlayFab Login

I've exported my game to HTML5 using Unreal Engine 4 and when I try to connect with a PlayFab account I receive the following error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://68cd.playfabapi.com/Client/LoginWithPlayFab. (Reason: missing token ‘pragma’ in CORS header ‘Access-Control-Allow-Headers’ from CORS preflight channel).
LogPlayFab: Error: Request failed: https://68CD.playfabapi.com/Client/LoginWithPlayFab

Is there a way through the PlayFab blueprint SDK to add the proper header with the request or is it typically put in the main .html file?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Can you try adding these header specifiers to your php file?

header('Access-Control-Allow-Origin: *');  
header('Access-Control-Allow-Methods: GET, POST');
header('Access-Control-Allow-Headers: content-type, pragma, x-unrealengine-agent');
7 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

starkgaminginc avatar image starkgaminginc commented ·

I've tried adding these to both the .htaccess file and my main php file and still no luck (among many other things).

Any other suggestions? I have a post going here:

https://answers.unrealengine.com/questions/756942/html5-cors-issue-to-my-hosted-server.html

0 Likes 0 ·
starkgaminginc avatar image starkgaminginc commented ·

On my post with UE4 it is suggesting the playfab host requires the “Access-Control-Allow-Origin: “*”

Is there anyway to add this to my game id api?

I can disable browser origin security (CORS) and the html5 game does connect with no issues.

0 Likes 0 ·
starkgaminginc avatar image starkgaminginc commented ·

Since the API host is gameid.playfab.com it should only affect my game id.

0 Likes 0 ·
brendan avatar image brendan starkgaminginc commented ·

We've actually got quite a lot of HTML5 games using the service, so my suspicion is that the problem is with the game's main page. What are the response headers coming from it?

0 Likes 0 ·
starkgaminginc avatar image starkgaminginc brendan commented ·

Error - Browser Console:

Failed to load https://68cd.playfabapi.com/Client/LoginWithPlayFab: Request header field Pragma is not allowed by Access-Control-Allow-Headers in preflight response.

See attached txt for headers playfab-headers.txt

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.