diff --git a/summer2024-frontend/.env.development b/summer2024-frontend/.env.development index 0271ae0..392809d 100644 --- a/summer2024-frontend/.env.development +++ b/summer2024-frontend/.env.development @@ -1 +1,3 @@ -VUE_APP_API_BASEURL=http://localhost:8080 \ No newline at end of file +VITE_API_BASEURL=http://localhost:8080 +VITE_S3_ENDPOINT=http://localhost:32771 +VITE_S3_BUCKET=assets diff --git a/summer2024-frontend/.env.production b/summer2024-frontend/.env.production new file mode 100644 index 0000000..61a9f95 --- /dev/null +++ b/summer2024-frontend/.env.production @@ -0,0 +1,3 @@ +VITE_API_BASEURL=https://api.summer2024.kektus.fr +VITE_S3_ENDPOINT=https://s3.kektus.fr +VITE_S3_BUCKET=kektus-summer2024-assets diff --git a/summer2024-frontend/src/config.js b/summer2024-frontend/src/config.js new file mode 100644 index 0000000..7a73a12 --- /dev/null +++ b/summer2024-frontend/src/config.js @@ -0,0 +1,3 @@ +export const API_BASE_URL = import.meta.env.VITE_API_BASEURL; +export const S3_ENDPOINT = import.meta.env.VITE_S3_ENDPOINT; +export const S3_BUCKET = import.meta.env.VITE_S3_BUCKET; diff --git a/summer2024-frontend/src/stores/adminPosts.js b/summer2024-frontend/src/stores/adminPosts.js index 370c674..a171425 100644 --- a/summer2024-frontend/src/stores/adminPosts.js +++ b/summer2024-frontend/src/stores/adminPosts.js @@ -1,6 +1,7 @@ import { defineStore } from 'pinia' import { ref } from 'vue' import { useAuthStore } from '@/stores/auth.js' +import { API_BASE_URL } from '@/config.js' export const useAdminPostsStore = defineStore("adminPosts", () => { const authStore = useAuthStore(); @@ -11,7 +12,7 @@ export const useAdminPostsStore = defineStore("adminPosts", () => { if (!authStore.isAuth) return - fetch("http://localhost:8080/admin/posts", { + fetch(API_BASE_URL + "/admin/posts", { headers: { "X-admin-token": authStore.adminToken } diff --git a/summer2024-frontend/src/stores/auth.js b/summer2024-frontend/src/stores/auth.js index 6d43b7c..2d3dd1f 100644 --- a/summer2024-frontend/src/stores/auth.js +++ b/summer2024-frontend/src/stores/auth.js @@ -1,5 +1,6 @@ import { defineStore } from 'pinia' import { ref } from 'vue' +import { API_BASE_URL } from '@/config.js' export const useAuthStore = defineStore("auth", () => { const adminToken = ref(""); @@ -11,7 +12,7 @@ export const useAuthStore = defineStore("auth", () => { isAuth.value = false; error.value = false; - return fetch("http://localhost:8080/admin/auth/check", { + return fetch(API_BASE_URL + "/admin/auth/check", { headers: { "X-admin-token": token } diff --git a/summer2024-frontend/src/stores/posts.js b/summer2024-frontend/src/stores/posts.js index 096ab73..d43b5d9 100644 --- a/summer2024-frontend/src/stores/posts.js +++ b/summer2024-frontend/src/stores/posts.js @@ -3,9 +3,10 @@ import { ref } from 'vue' import { formatRelative } from 'date-fns' import { fr } from 'date-fns/locale' import { marked } from 'marked' +import { API_BASE_URL } from '@/config.js' export const usePostsStore = defineStore('posts', () => { - const postsApiPath = 'http://localhost:8080/posts' + const postsApiPath = API_BASE_URL + '/posts' const posts = ref([]) diff --git a/summer2024-frontend/src/views/CreatePostView.vue b/summer2024-frontend/src/views/CreatePostView.vue index 879d4c9..490776e 100644 --- a/summer2024-frontend/src/views/CreatePostView.vue +++ b/summer2024-frontend/src/views/CreatePostView.vue @@ -19,6 +19,7 @@ import { import { Card, CardContent } from '@/components/ui/card/index.js' import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert/index.js' import { useAuthStore } from '@/stores/auth.js' +import { API_BASE_URL, S3_BUCKET, S3_ENDPOINT } from '@/config.js' const authStore = useAuthStore(); @@ -57,7 +58,7 @@ const onSubmit = form.handleSubmit(async (values) => { const assets = [] for (const file of selectedFiles.value) { console.log('Contact API asset') - const response = await fetch('http://localhost:8080/admin/assets', { + const response = await fetch(API_BASE_URL + '/admin/assets', { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -84,7 +85,7 @@ const onSubmit = form.handleSubmit(async (values) => { mediaUploadFormData.append('file', file.file, responseBody.filename) console.log('Envoi image sur s3') - const s3Response = await fetch('http://localhost:32795/assets/', { + const s3Response = await fetch(`${S3_ENDPOINT}/${S3_BUCKET}/`, { method: 'POST', body: mediaUploadFormData }) @@ -100,7 +101,7 @@ const onSubmit = form.handleSubmit(async (values) => { assets.push(responseBody.id) } - const response = await fetch('http://localhost:8080/admin/posts', { + const response = await fetch(API_BASE_URL + '/admin/posts', { method: 'POST', headers: { 'Content-Type': 'application/json',