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 at calling loadDevices #10

Open
ihardyslide opened this issue Jan 22, 2020 · 4 comments
Open

CORS issue at calling loadDevices #10

ihardyslide opened this issue Jan 22, 2020 · 4 comments

Comments

@ihardyslide
Copy link

Hi,

I'm currently trying to implement a web dashboard on top of your node-eufy-api.
Unfortunately, I can't access the Eufy API from the browser as it seems, failing with a CORS error:

Access to fetch at 'https://home-api.eufylife.com/v1/user/email/login' from origin 'http://localhost:8559' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Is there some way I can tell your library, that it should fetch the Eufy API with 'no-cors' option?

Thanks & br,
Marco

@sebmos
Copy link
Owner

sebmos commented Jan 22, 2020

That's not possible, because Eufy's servers don't let you create an connection from an arbitrary domain. To create a web dashboard, you have to create a Node JS server application, which your browser connects to. That application will then connect to Eufy servers & devices.

Keep in mind that in order to interact with Eufy devices, that server needs to be running on a server on the same Wifi network as your Eufy devices.

@ihardyslide
Copy link
Author

I see! Thanks!

@ihardyslide
Copy link
Author

ihardyslide commented Jan 22, 2020

Sorry if I highjack this issue for a follow up, but now everything is set up as proposed.
I am now getting Socket Closed error as soon as I try to .connect() to the lightbulb.
Any ideas?
image

Edit: They are in the same network btw!

@sebmos
Copy link
Owner

sebmos commented Jan 23, 2020

This looks like it's related to this issue #2.

This is something that affects some, but not all devices. This appears to be a bug in Eufy devices that they need to fix. The workaround would be to connect directly to Eufy's servers, which hasn't been achieved yet independently of Eufy. (At least as far as I can see.)

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

2 participants