Skip to content

Commit

Permalink
Definir automático a URL do backend no frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepenteado committed Oct 8, 2023
1 parent e9f20c0 commit 2616af5
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: npm --prefix ./controle/src/main/angular install

- name: Buildar frontend do módulo de controle
run: npm --prefix ./controle/src/main/angular run build --omit=dev -- "--base-href=/controle/"
run: npm --prefix ./controle/src/main/angular run build --omit=dev -- "--base-href=/controle/" "-c=production"

- name: Usar JDK 21
uses: actions/setup-java@v3
Expand Down
3 changes: 3 additions & 0 deletions .run/Backend UP.run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<configuration default="false" name="Backend UP" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<option name="ALTERNATIVE_JRE_PATH" value="Amazon Corretto JDK 21" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<envs>
<env name="BACKEND_URL" value="http://localhost:30001/controle" />
</envs>
<module name="controle" />
<option name="SPRING_BOOT_MAIN_CLASS" value="com.github.andrepenteado.apsso.controle.ApssoControleApplication" />
<method v="2" />
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build-controle:
docker logout ghcr.io

build-controle-pipeline:
npm --prefix ./controle/src/main/angular run build --omit=dev -- "--base-href=/controle/"
npm --prefix ./controle/src/main/angular run build --omit=dev -- "--base-href=/controle/" "-c=production"
mvn -U clean package --projects services,controle -DskipTests
docker build -f .docker/Dockerfile.controle.pipeline -t ghcr.io/andrepenteado/apsso/controle -t ghcr.io/andrepenteado/apsso/controle:$(VERSAO_APP) .
echo $(GITHUB_TOKEN) | docker login ghcr.io --username andrepenteado --password-stdin
Expand Down
2 changes: 1 addition & 1 deletion Makefile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ switch($exec) {
}
"build-controle-pipeline" {
$VERSAO = mvn help:evaluate `-Dexpression = project.version -q `-DforceStdout
npm --prefix ./controle/src/main/angular run build --omit=dev -- "--base-href=/controle/"
npm --prefix ./controle/src/main/angular run build --omit=dev -- "--base-href=/controle/" "-c=production"
mvn -U clean package --projects services,controle -DskipTests
docker build -f .docker/Dockerfile.controle.pipeline -t ghcr.io/andrepenteado/apsso/controle -t ghcr.io/andrepenteado/apsso/controle:$VERSAO .
Get-Content $GITHUB_TOKEN | docker login ghcr.io --username andrepenteado --password-stdin
Expand Down
2 changes: 1 addition & 1 deletion controle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<artifactId>controle</artifactId>
<packaging>jar</packaging>

<name>Backend do Módulo de Controle</name>
<name>Módulo de Controle</name>

<parent>
<groupId>com.github.andrepenteado</groupId>
Expand Down
6 changes: 0 additions & 6 deletions controle/src/main/angular/src/assets/env.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const environment = {
production: true,
backendURL: window['env']['backendUrl']
backendURL: window.location.protocol + '//' + window.location.host + '/controle'
};
2 changes: 1 addition & 1 deletion controle/src/main/angular/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

export const environment = {
production: false,
backendURL: 'http://localhost:30001/controle'
backendURL: window.location.protocol + '//' + window.location.host + '/controle'
};
/*
* For easier debugging in development mode, you can import the following file
Expand Down
1 change: 0 additions & 1 deletion controle/src/main/angular/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<link href="https://fonts.googleapis.com/css?family=Rubik:400,400i,500,500i,700,700i&amp;display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i,900&amp;display=swap" rel="stylesheet">
<script src="//cdn.ckeditor.com/4.7.1/full/ckeditor.js"></script>
<script src="assets/env.js"></script>
</head>

<body>
Expand Down

0 comments on commit 2616af5

Please sign in to comment.