jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.31k stars 4.01k forks source link

JHipster 7.1 -- TLS profile not working (Angular) #15655

Closed tcarlisle2012 closed 2 years ago

tcarlisle2012 commented 2 years ago
Overview of the issue

Generating a new app with jhipster, and selecting all the default answers, the TLS profile does not quite work. On the Spring Boot side, launching the back end with ./mvn -Pdev,tls works and the back end comes up with an https URL.

But on the Angular client side, the docs instrict to run: npm run start-tls

and that is not successful and procudes the error below:

mymediminder@0.0.1-SNAPSHOT start-tls npm run webapp:dev -- --env.tls

mymediminder@0.0.1-SNAPSHOT webapp:dev ng serve "--env.tls"

Unknown option: '--env.tls'

Motivation for or Use Case

It is important to be able to develop a webapp with SSL, as features such as service workers for FCM will not work if not using SSL.

Does anyone even develop http these days?

Reproduce the error

Run the generator and select all defaults

Then run: npm run start-tls

And you will see the error.

Related issues

I have found issues here dating back a few years which were resolved, and the discussion indicates it had to do with parameter passing down the webpack stack.

JHipster Version(s)

Using Jhipster 7.1.0

I cannot speak to whether it is a regression because I never tried this on jhipster previously.

JHipster configuration

Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
jhipstertls@0.0.1-SNAPSHOT /home/xxxxxxx/IdeaProjects/jhipster-tls-test
└── generator-jhipster@7.1.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "baseName": "jhipstertls",
    "jhipsterVersion": "7.1.0",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": [],
    "blueprints": [],
    "otherModules": [],
    "pages": [],
    "creationTimestamp": 1626199403824,
    "serviceDiscoveryType": false,
    "reactive": false,
    "authenticationType": "jwt",
    "packageName": "com.tomcsolutions.jhipstertest",
    "serverPort": "8080",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mariadb",
    "buildTool": "maven",
    "serverSideOptions": [],
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "enableSwaggerCodegen": false,
    "clientFramework": "angularX",
    "withAdminUi": true,
    "clientTheme": "flatly",
    "clientThemeVariant": "dark",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "packageFolder": "com/tomcsolutions/jhipstertest",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "devServerPort": 4200,
    "clientPackageManager": "npm",
    "languages": ["en"]
  }
}

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Environment and Tools

openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04) OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

git version 2.25.1

node: v14.17.2

npm: 7.19.1

No change to package.json was detected. No package manager install will be executed. Congratulations, JHipster execution is complete!

Here is package.json: "name": "jhipstertls", "version": "0.0.1-SNAPSHOT", "private": true, "description": "Description for jhipstertls", "license": "UNLICENSED", "scripts": { "prettier:check": "prettier --check \"{,src/*/,webpack/}.{md,json,yml,html,js,ts,tsx,css,scss,java}\"", "prettier:format": "prettier --write \"{,src/*/,webpack/}.{md,json,yml,html,js,ts,tsx,css,scss,java}\"", "lint": "eslint . --ext .js,.ts", "lint:fix": "npm run lint -- --fix", "cleanup": "rimraf target/classes/static/", "clean-www": "rimraf target/classes/static/app/{src,target/}", "jest": "jest --coverage --logHeapUsage --maxWorkers=2 --config jest.conf.js", "start": "ng serve --hmr", "start-tls": "npm run webapp:dev -- --env.tls", "serve": "npm run start", "build": "npm run webapp:prod", "pretest": "npm run lint", "test": "ng test --coverage --log-heap-usage -w=2", "test:watch": "npm run test -- --watch", "watch": "concurrently npm:start npm:backend:start", "webapp:build": "npm run clean-www && npm run webapp:build:dev", "webapp:build:dev": "ng build --configuration development", "webapp:build:prod": "ng build --configuration production", "webapp:dev": "ng serve", "webapp:dev-verbose": "ng serve --verbose", "webapp:prod": "npm run clean-www && npm run webapp:build:prod", "webapp:test": "npm run test", "docker:db:up": "docker-compose -f src/main/docker/mariadb.yml up -d", "docker:db:down": "docker-compose -f src/main/docker/mariadb.yml down -v --remove-orphans", "docker:others:await": "", "predocker:others:up": "", "docker:others:up": "", "docker:others:down": "", "ci:e2e:prepare:docker": "npm run docker:db:up && npm run docker:others:up && docker ps -a", "ci:e2e:prepare": "npm run ci:e2e:prepare:docker", "ci:e2e:teardown:docker": "npm run docker:db:down --if-present && npm run docker:others:down && docker ps -a", "ci:e2e:teardown": "npm run ci:e2e:teardown:docker", "backend:info": "./mvnw -ntp enforcer:display-info --batch-mode", "backend:doc:test": "./mvnw -ntp javadoc:javadoc --batch-mode", "backend:nohttp:test": "./mvnw -ntp checkstyle:check --batch-mode", "backend:start": "./mvnw -P-webapp", "java:jar": "./mvnw -ntp verify -DskipTests --batch-mode", "java:war": "./mvnw -ntp verify -DskipTests --batch-mode -Pwar", "java:docker": "./mvnw -ntp verify -DskipTests jib:dockerBuild", "backend:unit:test": "./mvnw -ntp -P-webapp verify --batch-mode -Dlogging.level.ROOT=OFF -Dlogging.level.org.zalando=OFF -Dlogging.level.tech.jhipster=OFF -Dlogging.level.com.tomcsolutions.jhipstertest=OFF -Dlogging.level.org.springframework=OFF -Dlogging.level.org.springframework.web=OFF -Dlogging.level.org.springframework.security=OFF", "backend:build-cache": "./mvnw dependency:go-offline", "java:jar:dev": "npm run java:jar -- -Pdev,webapp", "java:jar:prod": "npm run java:jar -- -Pprod", "java:war:dev": "npm run java:war -- -Pdev,webapp", "java:war:prod": "npm run java:war -- -Pprod", "java:docker:dev": "npm run java:docker -- -Pdev,webapp", "java:docker:prod": "npm run java:docker -- -Pprod", "ci:backend:test": "npm run backend:info && npm run backend:doc:test && npm run backend:nohttp:test && npm run backend:unit:test", "ci:server:package": "npm run java:$npm_package_config_packaging:$npm_package_config_default_environment", "ci:e2e:package": "npm run java:$npm_package_config_packaging:$npm_package_config_default_environment -- -Pe2e -Denforcer.skip=true", "preci:e2e:server:start": "npm run docker:db:await --if-present && npm run docker:others:await --if-present", "ci:e2e:server:start": "java -jar target/e2e.$npm_package_config_packaging --spring.profiles.active=$npm_package_config_default_environment -Dlogging.level.ROOT=OFF -Dlogging.level.org.zalando=OFF -Dlogging.level.tech.jhipster=OFF -Dlogging.level.com.tomcsolutions.jhipstertest=OFF -Dlogging.level.org.springframework=OFF -Dlogging.level.org.springframework.web=OFF -Dlogging.level.org.springframework.security=OFF --logging.level.org.springframework.web=ERROR", "ci:frontend:build": "npm run webapp:build:$npm_package_config_default_environment", "ci:frontend:test": "npm run ci:frontend:build && npm test" }, "config": { "backend_port": "8080", "default_environment": "prod", "packaging": "jar" }, "dependencies": { "@angular/common": "12.0.5", "@angular/compiler": "12.0.5", "@angular/core": "12.0.5", "@angular/forms": "12.0.5", "@angular/localize": "12.0.5", "@angular/platform-browser": "12.0.5", "@angular/platform-browser-dynamic": "12.0.5", "@angular/router": "12.0.5", "@fortawesome/angular-fontawesome": "0.9.0", "@fortawesome/fontawesome-svg-core": "1.2.35", "@fortawesome/free-solid-svg-icons": "5.15.3", "@ng-bootstrap/ng-bootstrap": "9.1.3", "@ngx-translate/core": "13.0.0", "@ngx-translate/http-loader": "6.0.0", "bootstrap": "4.6.0", "bootswatch": "4.6.0", "dayjs": "1.10.5", "ngx-infinite-scroll": "10.0.1", "ngx-webstorage": "8.0.0", "rxjs": "6.6.7", "swagger-ui-dist": "3.50.0", "tslib": "2.3.0", "zone.js": "0.11.4" }, "devDependencies": { "@angular-builders/custom-webpack": "12.1.0", "@angular-builders/jest": "12.1.0", "@angular-eslint/eslint-plugin": "12.1.0", "@angular/cli": "12.0.4", "@angular/compiler-cli": "12.0.5", "@angular/service-worker": "12.0.5", "@types/jest": "26.0.23", "@types/node": "15.12.2", "@typescript-eslint/eslint-plugin": "4.27.0", "@typescript-eslint/parser": "4.27.0", "browser-sync": "2.26.14", "browser-sync-webpack-plugin": "2.3.0", "concurrently": "6.2.0", "copy-webpack-plugin": "9.0.0", "eslint": "7.28.0", "eslint-config-prettier": "8.3.0", "eslint-webpack-plugin": "2.5.4", "generator-jhipster": "7.1.0", "husky": "4.3.8", "jest": "27.0.4", "jest-date-mock": "1.0.8", "jest-junit": "12.2.0", "jest-sonar-reporter": "2.0.0", "lint-staged": "11.0.0", "merge-jsons-webpack-plugin": "1.0.21", "prettier": "2.3.1", "prettier-plugin-java": "1.2.0", "prettier-plugin-packagejson": "2.2.11", "rimraf": "3.0.2", "ts-jest": "27.0.3", "typescript": "4.2.4", "wait-on": "5.3.0", "webpack-bundle-analyzer": "4.4.2", "webpack-merge": "5.8.0", "webpack-notifier": "1.13.0" }, "engines": { "node": ">=14.17.1" }, "cacheDirectories": [ "node_modules" ], "jestSonar": { "reportPath": "target/test-results/jest", "reportFile": "TESTS-results-sonar.xml" } }

Browsers and Operating System

I have done this on Ubuntu 20.04 platform and also on Windows 10 platform, with the same results.

carestra commented 2 years ago

I have the same problem using angular and reactive, see https://stackoverflow.com/questions/68742327/jhipster-v7-1-0-tls-support-in-dev-not-working-app-crashes-or-throw-exception

vogthenn commented 2 years ago

as a workaround, in package.json I replaced

"start-tls": "npm run webapp:dev -- --env.tls",

with

"start-tls": "npm run webapp:dev -- --env tls",

it worked, then, accessing to https. I'm very unsure about other implications, though, I'm at most a webpack beginner...