Skip to content

Commit dc377c3

Browse files
authored
client: adjust devServerPort (#28017)
1 parent c9558c6 commit dc377c3

File tree

16 files changed

+69
-38
lines changed

16 files changed

+69
-38
lines changed

generators/angular/templates/webpack/webpack.custom.js.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module.exports = async (config, options, targetOptions) => {
6969
new BrowserSyncPlugin(
7070
{
7171
host: 'localhost',
72-
port: 9000,
72+
port: <%- devServerPortProxy %>,
7373
https: tls,
7474
proxy: {
7575
target: `http${tls ? 's' : ''}://localhost:${targetOptions.target === 'serve' ? '<%= devServerPort %>' : '<%= applicationTypeMicroservice ? gatewayServerPort : serverPort %>'}`,
@@ -80,7 +80,7 @@ module.exports = async (config, options, targetOptions) => {
8080
proxyReq: [
8181
function (proxyReq) {
8282
// URI that will be retrieved by the ForwardedHeaderFilter on the server side
83-
proxyReq.setHeader('X-Forwarded-Host', 'localhost:9000');
83+
proxyReq.setHeader('X-Forwarded-Host', 'localhost:<%- devServerPortProxy %>');
8484
proxyReq.setHeader('X-Forwarded-Proto', 'https');
8585
},
8686
],

generators/app/__snapshots__/generator.spec.ts.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ exports[`generator - app with default config should match snapshot 1`] = `
326326
"devLiquibaseUrl": "jdbc:postgresql://localhost:5432/jhipster",
327327
"devR2dbcUrl": undefined,
328328
"devServerPort": 4200,
329+
"devServerPortProxy": 9000,
329330
"dockerContainers": {
330331
"apachepulsar/pulsar": "apachepulsar-pulsar-placeholder",
331332
"cassandra": "cassandra-placeholder",
@@ -991,6 +992,7 @@ exports[`generator - app with gateway should match snapshot 1`] = `
991992
"devLiquibaseUrl": "jdbc:postgresql://localhost:5432/jhipster",
992993
"devR2dbcUrl": "r2dbc:postgresql://localhost:5432/jhipster",
993994
"devServerPort": 4200,
995+
"devServerPortProxy": 9000,
994996
"dockerContainers": {
995997
"apachepulsar/pulsar": "apachepulsar-pulsar-placeholder",
996998
"cassandra": "cassandra-placeholder",
@@ -1651,6 +1653,7 @@ exports[`generator - app with microservice should match snapshot 1`] = `
16511653
"devLiquibaseUrl": "jdbc:postgresql://localhost:5432/jhipster",
16521654
"devR2dbcUrl": undefined,
16531655
"devServerPort": undefined,
1656+
"devServerPortProxy": undefined,
16541657
"dockerContainers": {
16551658
"apachepulsar/pulsar": "apachepulsar-pulsar-placeholder",
16561659
"cassandra": "cassandra-placeholder",

generators/client/command.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,20 @@ const command = {
8585
choices: ['webpack', 'vite'],
8686
scope: 'storage',
8787
},
88+
devServerPort: {
89+
cli: {
90+
type: Number,
91+
hide: true,
92+
},
93+
scope: 'storage',
94+
},
95+
devServerPortProxy: {
96+
cli: {
97+
type: Number,
98+
hide: true,
99+
},
100+
scope: 'storage',
101+
},
88102
microfrontend: {
89103
description: 'Enable microfrontend support',
90104
cli: {

generators/client/generator.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,10 @@ export default class JHipsterClientGenerator extends BaseApplicationGenerator {
8383
},
8484

8585
configureDevServerPort() {
86-
if (this.jhipsterConfig.devServerPort !== undefined) return;
86+
if (this.jhipsterConfig.devServerPort !== undefined || this.jhipsterConfig.applicationIndex === undefined) return;
8787

88-
const { clientFramework, applicationIndex } = this.jhipsterConfigWithDefaults;
89-
const devServerBasePort = clientFramework === ANGULAR ? 4200 : 9060;
90-
let devServerPort;
91-
92-
if (applicationIndex !== undefined) {
93-
devServerPort = devServerBasePort + applicationIndex;
94-
} else if (!devServerPort) {
95-
devServerPort = devServerBasePort;
96-
}
97-
98-
this.jhipsterConfig.devServerPort = devServerPort;
88+
const { applicationIndex, devServerPort } = this.jhipsterConfigWithDefaults;
89+
this.jhipsterConfig.devServerPort = devServerPort + applicationIndex;
9990
},
10091
});
10192
}

generators/docker-compose/generator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ export default class DockerComposeGenerator extends BaseWorkspacesGenerator {
196196
if (appConfig.devServerPort !== undefined) {
197197
deployment.keycloakRedirectUris += `"http://localhost:${appConfig.devServerPort}/*", `;
198198
}
199+
if (appConfig.devServerPortProxy !== undefined) {
200+
deployment.keycloakRedirectUris += `"http://localhost:${appConfig.devServerPortProxy}/*", `;
201+
}
199202
// Split ports by ":" and take last 2 elements to skip the hostname/IP if present
200203
const ports = yamlConfig.ports[0].split(':').slice(-2);
201204
ports[0] = appConfig.composePort;

generators/docker-compose/templates/realm-config/jhipster-realm.json.ejs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,14 +1074,12 @@
10741074
<%- keycloakRedirectUris %>
10751075
"http://localhost:8100/*",
10761076
"http://127.0.0.1:8761/*",
1077-
"http://localhost:9000/*",
10781077
"dev.localhost.ionic:*"
10791078
],
10801079
"webOrigins": [
10811080
<%- keycloakRedirectUris.replace(/\/\*/g, "") %>
10821081
"http://localhost:8100",
1083-
"http://127.0.0.1:8761",
1084-
"http://localhost:9000"
1082+
"http://127.0.0.1:8761"
10851083
],
10861084
"notBefore": 0,
10871085
"bearerOnly": false,

generators/java/generators/server/generator.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export default class ServerGenerator extends BaseApplicationGenerator {
9898
});
9999
},
100100
packageJsonE2eScripts({ application }) {
101+
const { devServerPort, devServerPortProxy: devServerPortE2e = devServerPort } = application;
101102
const scriptsStorage = this.packageJson.createStorage('scripts');
102103
const buildCmd = application.buildToolGradle ? 'gradlew' : 'mvnw -ntp';
103104

@@ -117,7 +118,7 @@ export default class ServerGenerator extends BaseApplicationGenerator {
117118
'ci:e2e:run': 'concurrently -k -s first -n application,e2e -c red,blue npm:ci:e2e:server:start npm:e2e:headless',
118119
'ci:e2e:dev': `concurrently -k -s first -n application,e2e -c red,blue "./${buildCmd}" npm:e2e:headless`,
119120
'e2e:dev': `concurrently -k -s first -n application,e2e -c red,blue "./${buildCmd}" npm:e2e`,
120-
'e2e:devserver': `concurrently -k -s first -n backend,frontend,e2e -c red,yellow,blue npm:backend:start npm:start "wait-on -t ${WAIT_TIMEOUT} http-get://127.0.0.1:9000 && npm run e2e:headless -- -c baseUrl=http://localhost:9000"`,
121+
'e2e:devserver': `concurrently -k -s first -n backend,frontend,e2e -c red,yellow,blue npm:backend:start npm:start "wait-on -t ${WAIT_TIMEOUT} http-get://127.0.0.1:${devServerPortE2e} && npm run e2e:headless -- -c baseUrl=http://localhost:${devServerPortE2e}"`,
121122
});
122123
}
123124
},

generators/kubernetes/__snapshots__/kubernetes.spec.ts.snap

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3572,19 +3572,17 @@ data:
35723572
"redirectUris": [
35733573
"http://jhgate.default.example.com/*",
35743574
"https://jhgate.default.example.com/*", "http://localhost:8080/*",
3575-
"https://localhost:8080/*",
3575+
"https://localhost:8080/*","http://localhost:4200/*", "http://localhost:9000/*",
35763576
"http://localhost:8100/*",
35773577
"http://127.0.0.1:8761/*",
3578-
"http://localhost:9000/*",
35793578
"dev.localhost.ionic:*"
35803579
],
35813580
"webOrigins": [
35823581
"http://jhgate.default.example.com",
35833582
"https://jhgate.default.example.com", "http://localhost:8080",
3584-
"https://localhost:8080",
3583+
"https://localhost:8080","http://localhost:4200", "http://localhost:9000",
35853584
"http://localhost:8100",
3586-
"http://127.0.0.1:8761",
3587-
"http://localhost:9000"
3585+
"http://127.0.0.1:8761"
35883586
],
35893587
"notBefore": 0,
35903588
"bearerOnly": false,
@@ -7007,19 +7005,17 @@ data:
70077005
"redirectUris": [
70087006
"http://jhgate.default.example.com/*",
70097007
"https://jhgate.default.example.com/*", "http://localhost:8080/*",
7010-
"https://localhost:8080/*",
7008+
"https://localhost:8080/*","http://localhost:4200/*", "http://localhost:9000/*",
70117009
"http://localhost:8100/*",
70127010
"http://127.0.0.1:8761/*",
7013-
"http://localhost:9000/*",
70147011
"dev.localhost.ionic:*"
70157012
],
70167013
"webOrigins": [
70177014
"http://jhgate.default.example.com",
70187015
"https://jhgate.default.example.com", "http://localhost:8080",
7019-
"https://localhost:8080",
7016+
"https://localhost:8080","http://localhost:4200", "http://localhost:9000",
70207017
"http://localhost:8100",
7021-
"http://127.0.0.1:8761",
7022-
"http://localhost:9000"
7018+
"http://127.0.0.1:8761"
70237019
],
70247020
"notBefore": 0,
70257021
"bearerOnly": false,

generators/kubernetes/files.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ export function writeFiles() {
121121
if (appConfig.devServerPort !== undefined) {
122122
this.keycloakRedirectUris += `"http://localhost:${appConfig.devServerPort}/*", `;
123123
}
124+
if (appConfig.devServerPortProxy !== undefined) {
125+
this.keycloakRedirectUris += `"http://localhost:${appConfig.devServerPortProxy}/*", `;
126+
}
124127

125128
this.debug(chalk.red.bold(`${appConfig.baseName} has redirect URIs ${this.keycloakRedirectUris}`));
126129
this.debug(chalk.red.bold(`AppConfig is ${JSON.stringify(appConfig)}`));

generators/kubernetes/templates/keycloak/keycloak-configmap.yml.ejs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,14 +1038,12 @@ data:
10381038
<%- keycloakRedirectUris %>
10391039
"http://localhost:8100/*",
10401040
"http://127.0.0.1:8761/*",
1041-
"http://localhost:9000/*",
10421041
"dev.localhost.ionic:*"
10431042
],
10441043
"webOrigins": [
10451044
<%- keycloakRedirectUris.replace(/\/\*/g, "") %>
10461045
"http://localhost:8100",
1047-
"http://127.0.0.1:8761",
1048-
"http://localhost:9000"
1046+
"http://127.0.0.1:8761"
10491047
],
10501048
"notBefore": 0,
10511049
"bearerOnly": false,

0 commit comments

Comments
 (0)