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

XHR PUT/DELETE Requests on Electron Browser fail with Http Failure Response #2930

Closed
andrewryan1906 opened this issue Dec 11, 2018 · 2 comments

Comments

@andrewryan1906
Copy link

andrewryan1906 commented Dec 11, 2018

Current behavior:

I have a set of tests that run against an Angular 7 application with no problem on the Chrome browser. This same set, however, fails when running on the Electron 59 browser. It's consistent and reproducible for me; upon further inspection, I noticed that all of the tests that fail do so when making PUT or DELETE requests to my back end REST API; POST requests function properly, and the tests that use them pass. So my "create" tests pass, whereas my "edit" and "delete" tests fail. The error screen:

cypress-screenshot

You can see the error Http failure response for (unknown url): 0 Unknown Error

I turned on debugging and was unable to see anything in the XHDR outputs in the logs, and thus could not reproduce the problem.

Desired behavior:

Tests should run properly both in Electron 59 and in Chrome.

Steps to reproduce: (app code and test code)

If you'd like, I can add you to my application repo so you can run the failing test yourself. As I said, the challenge is that it only fails when running Electron; it behaves properly in Chrome. Reply with your username and I will give you access to the repo.

Versions

Cypress 3.1.3, Windows 10
Using API Gateway/Lambda for the backend, and CORS is properly configured.

@andrewryan1906 andrewryan1906 changed the title XHDR PUT/DELETE Requests on Electron Browser fail with Http Failure Response XHR PUT/DELETE Requests on Electron Browser fail with Http Failure Response Dec 11, 2018
@andrewryan1906
Copy link
Author

andrewryan1906 commented Dec 11, 2018

A bit more info.. I ran the Electron browser headed and was able to reproduce. This time, I got access to the developer console, and the error I'm seeing is:

XMLHttpRequest cannot load https://api.rolodex.us-east-2-992899858538.mydomain.com/v1/tests/customActivityTypes/CYPRESS_ACTIVITY_TYPE. Method PUT is not allowed by Access-Control-Allow-Methods in preflight response.

This doesn't make sense, since I have CORS enabled and all of my API gateways, everything works in Chrome, and it's been working for ages. I double checked and the pre-flight OPTIONS request is indeed returning properly... screenshot:

cors_preflight

So the problem is, the Electron browser is not honoring the response from the pre-flight OPTIONS request the way Chrome is. Can't find anything on the web about what might be causing this.... any help appreciated.

@andrewryan1906
Copy link
Author

OK,

I've done a bit more work and was able to identify the issue. I thought it was really weird that Electron accepted the CORS headers for GET/POST, but not PUT/DELETE. For giggles, I tried to delineate all of the CORS methods that were allowed, so I went to API Gateway and changed the CORS output from:

Access-Control-Allow-Methods: '*'

to

Access-Control-Allow-Methods: 'GET,PUT,POST,DELETE,OPTIONS'

And lo and behold, everything works. Not sure why this is, but I'm going to leave this issue open in case you have additional insights/comments.

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

1 participant