mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 19:53:21 +02:00
Added .env access to frontend (+ while dockerized)
This commit is contained in:
@@ -8,8 +8,8 @@ const router = createRouter({
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'home',
|
||||
component: Home
|
||||
name: 'login',
|
||||
component: Login
|
||||
},
|
||||
{
|
||||
path: '/debug',
|
||||
@@ -17,9 +17,9 @@ const router = createRouter({
|
||||
component: Debug
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
component: Login
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
component: Home
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ const email = ref('')
|
||||
const password = ref('')
|
||||
|
||||
function getArticles() {
|
||||
fetch(`http://localhost:8080/articles/`, {
|
||||
fetch(`http://localhost:${__APP_ENV__.API_PORT}/articles/`, {
|
||||
headers: { "Authorization": `Bearer ${useAuthStore().token}` }
|
||||
})
|
||||
.then(response => response.json())
|
||||
@@ -25,7 +25,7 @@ function jwtHandler(apiResponse: jwtFormat): void {
|
||||
}
|
||||
|
||||
function login(email: string, password: string): void {
|
||||
fetch(`http://localhost:8080/login/`, {
|
||||
fetch(`http://localhost:${__APP_ENV__.API_PORT}/login/`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
|
||||
@@ -16,8 +16,9 @@ function jwtHandler(apiResponse: jwtFormat): void {
|
||||
isTokenOK.value = true
|
||||
}
|
||||
|
||||
//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:8080/login/`, {
|
||||
fetch(`http://localhost:${__APP_ENV__.API_PORT}/login/`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
@@ -28,7 +29,7 @@ function login(email: string, password: string): void {
|
||||
.then(result => {
|
||||
jwtHandler(result)
|
||||
if (isTokenOK.value === true) {
|
||||
router.push('/')
|
||||
router.push('/home')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user