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

Doesn't work with https for webpack-dev-server #170

Open
praneetha-ck-robo opened this issue May 3, 2019 · 7 comments
Open

Doesn't work with https for webpack-dev-server #170

praneetha-ck-robo opened this issue May 3, 2019 · 7 comments

Comments

@praneetha-ck-robo
Copy link

praneetha-ck-robo commented May 3, 2019

Thank you for taking time to open a new issue. Please answer a few questions to help us fix it faster. You can delete text that is irrelevant to the issue.

Is this a bug report or a feature request?

Version
"start-server-and-test": "^1.9.0"
"cypress": "^3.2.0",

Platform
macOs High Sierra - Version 10.13.6

I am using create-react-app and I am running my development webpack server in https.
So running npm run cypress:open, I would expect

  1. My application to run in https://localhost:3000
  2. Once the server is up, the cypress launcher to run on it.

Only the first step happens, cypress launcher is not opening up.

This is my scripts config in package.json.

 "scripts": {
        "watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
        "start-js": "export HTTPS=true&&react-scripts start",
        "start": "npm-run-all -p watch-css start-js",
        "cy:open": "cypress open",
        "cypress:open": "start-server-and-test start http-get://localhost:3000 cy:open"
    },

I am facing this issue only for https, not http.

@rajzik
Copy link

rajzik commented May 6, 2019

Change http-get://localhost:3000 to https-get://localhost:3000 this should resolve your issue.
If not try following script:
START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start http-get://localhost:3000 cy:open.

@rodoabad
Copy link

rodoabad commented May 16, 2019

Piggybacking on this thread.

#163

Does that mean @rajzik that if I have two servers...

{
  "scripts": {
    "test": "node src/test",
    "start:api": "node src/api",
    "start:server": "node src/server",
    "start:server-and-api": "start-test start:api 7600 start:server",
    "test:all": "start-test start:server-and-api http-get://localhost:3000 test"
  }
}

If I do this I get...

TypeError: Cannot read property 'indexOf' of undefined
[./node_modules/webpack-dev-server/client/index.js?http://localhost:5555] (webpack)-dev-server/client?http://localhost:5555 8.1 KiB {main} [built]
    + 1202 hidden modules
ℹ 「wdm」: Compiled successfully.
TypeError: Cannot read property 'indexOf' of undefined

My server starts at http://localhost:3000/#/ do I need to include the hash?

@rajzik
Copy link

rajzik commented Jun 6, 2019

@rodoabad
The error comes from where?

If you have some sort of routing inside of your application and you get redirected from / to /#/ it shouldn't be problem.

start-test waiting for response from sever. Also it looks like something running on port 5555, maybe it's only debugging port.

There might be problem with timing of your servers.
start-test waits only for one server.

@goldylucks
Copy link

@rajzik

Change http-get://localhost:3000 to https-get://localhost:3000 this should resolve your issue.
If not try following script:
START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start http-get://localhost:3000 cy:open.

I can confirm this works for me:

// package.json
    "start": "HTTPS=true PORT=3001 react-app-rewired start",
    "cy:run": "cypress run",
    "cy:ci": "START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start:ci https-get://localhost:3001 cy:run",

@praneetha-ck-robo , can you try this and tell if it works?

@goldylucks
Copy link

@rodoabad you can try to isolate what is causing the error. Try each command separately:

  "scripts": {
    "test": "node src/test",
    "start:api": "node src/api",
    "start:server": "node src/server",
    "start:server-and-api": "start-test start:api 7600 start:server",
    "test:all": "start-test start:server-and-api http-get://localhost:3000 test"
  }

this is step 1, to validate the problem is actually in test:all.

If your server runs on https, see my previous comment

@jamiehaywood
Copy link

jamiehaywood commented Oct 11, 2020

I'm also having this problem with CRA (react-scripts v3.4.3).

The way my HTTPS is set is in my .env file:

HTTPS=true
SSL_CRT_FILE=./.cert/cert.pem
SSL_KEY_FILE=./.cert/key.pem

I've tried the answer you suggested @goldylucks, however it seems that when the Webpack server starts it hijacks / overrides the rest of the script.

My workaround was to execute this script:

HTTPS=false start-server-and-test start:pwa http-get://localhost:3000 cy:run

@finnmerlett
Copy link

Just chipping in to add that I was trying to run end-to-end tests on my Create React App on localhost with https enabled. Initially the server would start but then the test would not get triggered, but by adding the command START_SERVER_AND_TEST_INSECURE=1 before running start-server-and-test it worked perfectly.

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

6 participants