Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS issue when using custom api #282

Closed
alanhamlett opened this issue Oct 2, 2024 · 4 comments
Closed

CORS issue when using custom api #282

alanhamlett opened this issue Oct 2, 2024 · 4 comments
Assignees

Comments

@alanhamlett
Copy link
Member

          @alanhamlett it's still broken, bot now I tried to deep dive into the root of the problem and I found the following: when the plugin tries to access https://wakapi.dev/api/ (this is an alternative wakapi server, it's not the "official") it gets a CORS error with the latest versions (3.0.24, 4.0.0, 4.0.1) of the plugin:

[XHR] [POST] https://wakapi.dev/api/users/current/heartbeats.bulk?api_key=(...)

TypeError: NetworkError when attempting to fetch resource. WakaTimeCore.ts:249:14
sendHeartbeats WakaTimeCore.ts:249
handleActivity WakaTimeCore.ts:123
<névtelen> background.ts:58

Cross-Origin request blocked: Same-origin policy does not allow reading remote resource from https://wakapi.dev/api/users/current/heartbeats.bulk?api_key=(...). (Reason: CORS header "Access-Control-Allow-Origin" is missing). Status code: 400.

I don't really know whether it is a problem with wakapi.dev server's config, or it can be fixed on client side, but I hope it can help you to understand the issue.

Originally posted by @Atko in #261 (comment)

@alanhamlett alanhamlett self-assigned this Oct 2, 2024
@alanhamlett
Copy link
Member Author

I'm not able to reproduce this on the latest version 4.0.5. It's sending without errors for me. I'm running it by loading as an unpacked extension after running npm run watch but it should be the same as running from the chrome web store.

@Atko
Copy link

Atko commented Oct 28, 2024

@alanhamlett I think you were able to figure out this issue with custom API url, because the latest (4.0.9) ffox version of the plugin sends heartbeats perfectly to a wakapi.dev instance.
It might be the related wakapi issue: muety/wakapi#688

(I hate it too if somebody comments a closed issue, but I didn't want to reopen it, I just wanted you to know that this issue was solved. :) )

@alanhamlett
Copy link
Member Author

Thanks for updating, and verifying it's fixed!

@GamingLiamStudios
Copy link

GamingLiamStudios commented Oct 31, 2024

Sorry if it's necroposting here a bit, but on 4.0.9 running Firefox Nightly 134.0a1 (Oct 31), I'm getting empty POST requests & CORS errors from the OPTIONS requests.

The OPTIONS request returns a 405 w/ error "CORS Missing Allow Origin".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants