mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
Added host address to .env
This commit is contained in:
@@ -12,8 +12,9 @@ docker-compose up
|
||||
TODO
|
||||
## Environment variables
|
||||
- ./env
|
||||
- API_PORT
|
||||
- FRONT_PORT
|
||||
- JWT_SECRET
|
||||
- APP_HOST_ADDRESS
|
||||
- APP_API_PORT
|
||||
- APP_FRONT_PORT
|
||||
- APP_JWT_SECRET
|
||||
## Demo
|
||||
TODO
|
||||
+2
-2
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
var ginMode = os.Getenv("GIN_MODE")
|
||||
var ginMode = os.Getenv("APP_GIN_MODE")
|
||||
|
||||
func initEnvVariables() {
|
||||
if godotenv.Load() != nil {
|
||||
@@ -67,7 +67,7 @@ func initGin() {
|
||||
initBasicRoutes(r)
|
||||
initArticlesRoutes(r)
|
||||
|
||||
r.Run(":" + os.Getenv("API_PORT"))
|
||||
r.Run(":" + os.Getenv("APP_API_PORT"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ services:
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "${API_PORT}:${API_PORT}"
|
||||
- "${APP_API_PORT}:${APP_API_PORT}"
|
||||
networks:
|
||||
- back-net
|
||||
frontend:
|
||||
@@ -18,7 +18,7 @@ services:
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- "${FRONT_PORT}:80"
|
||||
- "${APP_FRONT_PORT}:80"
|
||||
networks:
|
||||
- front-net
|
||||
db:
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ var UsersLocation = Location{Database: "gohcms", Collection: "users"}
|
||||
|
||||
var AuthMiddleware, _ = jwt.New(&jwt.GinJWTMiddleware{
|
||||
Realm: "GohCMS",
|
||||
Key: []byte(os.Getenv("JWT_SECRET")),
|
||||
Key: []byte(os.Getenv("APP_JWT_SECRET")),
|
||||
Timeout: time.Hour,
|
||||
MaxRefresh: time.Hour,
|
||||
Authenticator: JWTAuthenticator,
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
export interface Pong {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export async function pingApi(): Promise<String> {
|
||||
let result: String = ''
|
||||
await fetch('http://localhost:8080/ping')
|
||||
.then(response => response.json())
|
||||
.then(jsonResponse => result = jsonResponse.message)
|
||||
return result
|
||||
}
|
||||
@@ -6,8 +6,18 @@ import { ref } from 'vue';
|
||||
const email = ref('')
|
||||
const password = ref('')
|
||||
|
||||
const baseURL = `http://${__APP_ENV__.APP_HOST_ADDRESS}:${__APP_ENV__.APP_API_PORT}`
|
||||
|
||||
function getArticles() {
|
||||
fetch(`http://localhost:${__APP_ENV__.API_PORT}/articles/`, {
|
||||
fetch(`${baseURL}/articles/`, {
|
||||
headers: { "Authorization": `Bearer ${useAuthStore().token}` }
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(result => console.log(result))
|
||||
}
|
||||
|
||||
function ping() {
|
||||
fetch(`${baseURL}/ping/`, {
|
||||
headers: { "Authorization": `Bearer ${useAuthStore().token}` }
|
||||
})
|
||||
.then(response => response.json())
|
||||
@@ -25,7 +35,7 @@ function jwtHandler(apiResponse: jwtFormat): void {
|
||||
}
|
||||
|
||||
function login(email: string, password: string): void {
|
||||
fetch(`http://localhost:${__APP_ENV__.API_PORT}/login/`, {
|
||||
fetch(`${baseURL}/login/`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
@@ -54,10 +64,8 @@ function login(email: string, password: string): void {
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<button @click="getArticles()">get all articles</button>
|
||||
<button @click="getArticles()">get all articles</button>
|
||||
<button @click="getArticles()">get all articles</button>
|
||||
<button @click="getArticles()">get all articles</button>
|
||||
<button class="button-primary" @click="getArticles()">get all articles</button>
|
||||
<button class="button-primary" @click="ping()">ping</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -18,7 +18,7 @@ function jwtHandler(apiResponse: jwtFormat): void {
|
||||
|
||||
//TODO rempalcer tous les :8080 par la var d'env du port de l'API (sinon c un peu dommage)
|
||||
function login(email: string, password: string): void {
|
||||
fetch(`http://localhost:${__APP_ENV__.API_PORT}/login/`, {
|
||||
fetch(`http://${__APP_ENV__.APP_HOST_ADDRESS}:${__APP_ENV__.APP_API_PORT}/login/`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
|
||||
Reference in New Issue
Block a user