claabs / epicgames-freegames-node

Automatically login and find available free games the Epic Games Store. Sends you a prepopulated checkout link so you can complete the checkout after logging in. Supports multiple accounts, login sessions, and scheduled runs.
https://hub.docker.com/r/charlocharlie/epicgames-freegames
MIT License
1.33k stars 90 forks source link

hCaptcha element CORS issues #85

Closed claabs closed 3 years ago

claabs commented 3 years ago

fce.stinosko.com-1612455032211.log I'm getting the same issue, see console log: Access to XMLHttpRequest at 'https://hcaptcha.com/checksiteconfig?host=fce.stinosko.com&sitekey=91e4137f-95af-4bc9-97af-cdcedce21c8c&sc=1&swa=1' from origin 'http://fce.stinosko.com:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'https://assets.hcaptcha.com' that is not equal to the supplied origin. fce.stinosko.com points to my server where I'm running the script on.

I pulled latest docker container to verify i'm on the latest version.

Originally posted by @Stinosko in https://github.com/claabs/epicgames-freegames-node/issues/60#issuecomment-773426483

claabs commented 3 years ago

My theory on this issue is that it's due to a non-localhost, non-https, domain name with a port suffix, which is a use case I haven't tested yet.

Freekers commented 3 years ago

I'm facing the same issue, yet I do have a HTTPs domain name on port 443, albeit via a reverse proxy. The container itself runs on port 8090.

claabs commented 3 years ago

I just tested the port suffix situation and it works fine. I think the solution to this problem is to clear any cache, since the JS really likes to get cached.

During development, I had to purge my Cloudflare cache and any browser cached stuff (shift+F5) to get it to pull the new JS that has the text replacements that fix the CORS issues. The new JS is served from the container with caching disabled, so it should stay fresh from here on out.

So yeah, just clear your cache.

Freekers commented 3 years ago

OK, I will try and report back. Thanks! PS. Perhaps the cache can be controlled via HTTP headers?

Stinosko commented 3 years ago

Clearing cache worked!

So weird as the issue was present on both firefox and edge (chromium) browser on my computer and on mobile browser. I daily use firefox and use edge only when firefox is having issue displaying something...

Glad this solved it!

claabs commented 3 years ago

I use nocache in express to kill the caching, but IDK if it actually affects the proxied JS calls.