Skip to content

Commit

Permalink
fix api host name
Browse files Browse the repository at this point in the history
  • Loading branch information
riadh-benchouche committed Dec 7, 2023
1 parent ae1d607 commit 6c11fbf
Show file tree
Hide file tree
Showing 19 changed files with 48 additions and 47 deletions.
1 change: 1 addition & 0 deletions client/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_HOST_API=https://api.sneakpeak.fr
5 changes: 3 additions & 2 deletions client/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import './assets/main.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import {createApp} from 'vue'
import {createPinia} from 'pinia'
import Toast from 'vue3-toastify';
import 'vue3-toastify/dist/index.css';


import App from './App.vue'
import router from './router'

console.log(import.meta.env)
const app = createApp(App)

app.use(createPinia())
Expand Down
2 changes: 1 addition & 1 deletion client/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ router.beforeEach(async (to, from, next) => {
} else {
if (loggedIn) {
try {
const response = await fetch(`http://localhost:3000/auth/check-if-authenticated`, {
const response = await fetch(`${import.meta.env.VITE_HOST_API}/auth/check-if-authenticated`, {
headers: {
Authorization: `Bearer ${token}`
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/stores/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const useUserStore = defineStore({

async fetchUser() {
try {
const response = await axios.get('http://localhost:3000/auth/user');
const response = await axios.get(`${import.meta.env.VITE_HOST_API}/auth/user`);

if (response.status === 200) {
this.user = response.data;
Expand Down
2 changes: 1 addition & 1 deletion client/src/types/ProductImageType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type ProductImageType = {

export const getProductImage = (product: ProductType, index = 0) => {
if (product?.productImages?.length > 0) {
return `http://localhost:3000/images/${product.productImages[index].url}`
return `${import.meta.env.VITE_HOST_API}/images/${product.productImages[index].url}`
} else {
return '/images/no-image.jpeg'
}
Expand Down
4 changes: 1 addition & 3 deletions client/src/utils/axiosInstance.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import axios from "axios";
import.meta.env.PROD;


const axiosInstance = axios.create({
baseURL: import.meta.env.PROD ? "https://api.sneakpeak.fr" : "http://localhost:3000",
baseURL: import.meta.env.VITE_HOST_API,
});

axiosInstance.interceptors.request.use(
Expand Down
18 changes: 9 additions & 9 deletions client/src/views/ProductView.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<script setup lang="ts">
import LayoutComponent from '@/layout/LayoutComponent.vue'
import { reactive } from 'vue'
import { useRouter } from 'vue-router'
import { useWishlistStore } from '@/stores/wishlist'
import {reactive} from 'vue'
import {useRouter} from 'vue-router'
import {useWishlistStore} from '@/stores/wishlist'
import axiosInstance from '@/utils/axiosInstance'
import type { ProductType } from '@/types/ProductType'
import { getProductColor, getProductPrice } from '@/types/ProductType'
import { getProductImage } from '@/types/ProductImageType'
import { useCartStore } from '@/stores/cart'
import type {ProductType} from '@/types/ProductType'
import {getProductColor, getProductPrice} from '@/types/ProductType'
import {getProductImage} from '@/types/ProductImageType'
import {useCartStore} from '@/stores/cart'
import RedirectModal from '@/components/RedirectModal.vue'
import checkAuthentication from '@/utils/checkAuthentication'
import { ExclamationCircleIcon } from '@heroicons/vue/24/outline'
import {ExclamationCircleIcon} from '@heroicons/vue/24/outline'
const product = {
highlights: [
Expand Down Expand Up @@ -74,7 +74,7 @@ init()
class="aspect-h-5 aspect-w-4 lg:aspect-h-4 lg:aspect-w-3 sm:overflow-hidden sm:rounded-lg"
>
<img
:src="`http://localhost:3000/images/${image.url}`"
:src="`${import.meta.env.VITE_HOST_API}/images/${image.url}`"
:alt="state.product.name"
class="h-full w-full object-cover object-center"
/>
Expand Down
6 changes: 3 additions & 3 deletions client/src/views/auth/ProfileView.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script setup lang="ts">
import { reactive } from 'vue'
import {reactive} from 'vue'
import axiosInstance from '@/utils/axiosInstance'
import UserProfileField from '@/components/profile/UserProfileField.vue'
import UserProfilePasswordFields from '@/components/profile/UserProfilePasswordFields.vue'
import UserProfileSwitchField from '@/components/profile/UserProfileSwitchField.vue'
import LayoutComponent from '@/layout/LayoutComponent.vue'
import HistorySection from '@/sections/profile/HistorySection.vue'
import { CloudArrowDownIcon } from '@heroicons/vue/24/outline'
import {CloudArrowDownIcon} from '@heroicons/vue/24/outline'
const state: { user: any; tabs: any[]; currentModifications: any; notifications: { label: string, value: boolean }[] } = reactive({
Expand Down Expand Up @@ -87,7 +87,7 @@ const exportPersonalData = async () => {
const exportId = res.data.exportId
const downloadLink = document.createElement('a')
downloadLink.href = `http://localhost:3000/exports/${fileName}`
downloadLink.href = `${import.meta.env.VITE_HOST_API}/exports/${fileName}`
downloadLink.download = fileName
document.body.appendChild(downloadLink)
downloadLink.click()
Expand Down
1 change: 1 addition & 0 deletions dashboard/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_HOST_API=https://api.sneakpeak.fr
2 changes: 1 addition & 1 deletion dashboard/src/stores/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const useUserStore = defineStore({

async fetchUser() {
try {
const response = await axios.get('http://localhost:3000/auth/user');
const response = await axios.get(`${import.meta.env.VITE_HOST_API}/auth/user`);

if (response.status === 200) {
this.user = response.data;
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/utils/axiosInstance.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";

const axiosInstance = axios.create({
baseURL: "http://localhost:3000",
baseURL: import.meta.env.VITE_HOST_API,
});

axiosInstance.interceptors.request.use(
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/utils/valuesUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const getImages = (productImages: any) => {
}

return productImages.map((productImage: any) => {
return `http://localhost:3000/images/${productImage.url}`
return `${import.meta.env.VITE_HOST_API}/images/${productImage.url}`
})
}

Expand All @@ -69,7 +69,7 @@ const getFirstImage = (productImages: any) => {
return ''
}

return `http://localhost:3000/images/${productImages[0].url}`
return `${import.meta.env.VITE_HOST_API}/images/${productImages[0].url}`
}

const getModel = (model: any) => {
Expand Down
8 changes: 4 additions & 4 deletions dashboard/src/views/brands/BrandsView.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script setup lang="ts">
import AuthenticatedLayout from '@/layouts/AuthenticatedLayout.vue'
import axiosInstance from '@/utils/axiosInstance'
import { onMounted, onUnmounted, reactive } from 'vue'
import {onMounted, onUnmounted, reactive} from 'vue'
import OTable from '@/components/OTable.vue'
import OModal from '@/components/OModal.vue'
import { useRouter } from 'vue-router'
import {useRouter} from 'vue-router'
import BrandsSidebarForm from '@/views/brands/BrandsSidebarForm.vue'
import { CloudArrowDownIcon } from '@heroicons/vue/24/outline'
import {CloudArrowDownIcon} from '@heroicons/vue/24/outline'
const router = useRouter()
const state = reactive({
Expand Down Expand Up @@ -73,7 +73,7 @@ const exportBrands = async () => {
const fileName = res.data.fileName
const downloadLink = document.createElement('a')
downloadLink.href = `http://localhost:3000/exports/${fileName}`
downloadLink.href = `${import.meta.env.VITE_HOST_API}/exports/${fileName}`
downloadLink.download = fileName
document.body.appendChild(downloadLink)
downloadLink.click()
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/views/categories/CategoriesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import OTable from "@/components/OTable.vue";
import {useRouter} from "vue-router";
import OModal from "@/components/OModal.vue";
import CategoriesSidebarForm from "@/views/categories/CategoriesSidebarForm.vue";
import { CloudArrowDownIcon } from '@heroicons/vue/24/outline';
import {CloudArrowDownIcon} from '@heroicons/vue/24/outline';
const router = useRouter()
const state = reactive({
Expand Down Expand Up @@ -79,7 +79,7 @@ const exportCategories = async () => {
const fileName = res.data.fileName
const downloadLink = document.createElement('a')
downloadLink.href = `http://localhost:3000/exports/${fileName}`
downloadLink.href = `${import.meta.env.VITE_HOST_API}/exports/${fileName}`
downloadLink.download = fileName
document.body.appendChild(downloadLink)
downloadLink.click()
Expand Down
6 changes: 3 additions & 3 deletions dashboard/src/views/exports/ExportsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const OpenConfirmationModal = (exportItem: any) => {
const downloadExport = async (fileName: string) => {
try {
const downloadLink = document.createElement('a')
downloadLink.href = `http://localhost:3000/exports/${fileName}`
downloadLink.href = `${import.meta.env.VITE_HOST_API}/exports/${fileName}`
downloadLink.download = fileName
document.body.appendChild(downloadLink)
downloadLink.click()
Expand All @@ -54,7 +54,7 @@ const exportUsers = async () => {
const fileName = res.data.fileName
const downloadLink = document.createElement('a')
downloadLink.href = `http://localhost:3000/exports/${fileName}`
downloadLink.href = `${import.meta.env.VITE_HOST_API}/exports/${fileName}`
downloadLink.download = fileName
document.body.appendChild(downloadLink)
downloadLink.click()
Expand All @@ -76,7 +76,7 @@ const exportProducts = async () => {
const fileName = res.data.fileName
const downloadLink = document.createElement('a')
downloadLink.href = `http://localhost:3000/exports/${fileName}`
downloadLink.href = `${import.meta.env.VITE_HOST_API}/exports/${fileName}`
downloadLink.download = fileName
document.body.appendChild(downloadLink)
downloadLink.click()
Expand Down
4 changes: 2 additions & 2 deletions dashboard/src/views/models/ModelsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import OTable from "@/components/OTable.vue";
import {onUnmounted, reactive} from "vue";
import type {ModelType} from "@/types/ModelType";
import {useRouter} from "vue-router";
import { CloudArrowDownIcon } from '@heroicons/vue/24/outline';
import {CloudArrowDownIcon} from '@heroicons/vue/24/outline';
const state = reactive({
openCreation: false,
Expand Down Expand Up @@ -82,7 +82,7 @@ const exportModels = async () => {
const fileName = res.data.fileName
const downloadLink = document.createElement('a')
downloadLink.href = `http://localhost:3000/exports/${fileName}`
downloadLink.href = `${import.meta.env.VITE_HOST_API}/exports/${fileName}`
downloadLink.download = fileName
document.body.appendChild(downloadLink)
downloadLink.click()
Expand Down
8 changes: 4 additions & 4 deletions dashboard/src/views/orders/OrdersView.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import AuthenticatedLayout from '@/layouts/AuthenticatedLayout.vue'
import axiosInstance from '@/utils/axiosInstance'
import { onMounted, onUnmounted, reactive } from 'vue'
import {onMounted, onUnmounted, reactive} from 'vue'
import OTable from '@/components/OTable.vue'
import { useRouter } from 'vue-router'
import { CloudArrowDownIcon } from '@heroicons/vue/24/outline'
import {useRouter} from 'vue-router'
import {CloudArrowDownIcon} from '@heroicons/vue/24/outline'
const router = useRouter()
const state = reactive({
Expand Down Expand Up @@ -34,7 +34,7 @@ const exportOrders = async () => {
const fileName = res.data.fileName
const downloadLink = document.createElement('a')
downloadLink.href = `http://localhost:3000/exports/${fileName}`
downloadLink.href = `${import.meta.env.VITE_HOST_API}/exports/${fileName}`
downloadLink.download = fileName
document.body.appendChild(downloadLink)
downloadLink.click()
Expand Down
8 changes: 4 additions & 4 deletions dashboard/src/views/products/ProductsView.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script setup lang="ts">
import AuthenticatedLayout from '@/layouts/AuthenticatedLayout.vue'
import axiosInstance from '@/utils/axiosInstance'
import { onMounted, onUnmounted, reactive } from 'vue'
import {onMounted, onUnmounted, reactive} from 'vue'
import OTable from '@/components/OTable.vue'
import { useRouter } from 'vue-router'
import {useRouter} from 'vue-router'
import OModal from '@/components/OModal.vue'
import ProductsSidebarForm from './ProductsSidebarForm.vue'
import { CloudArrowDownIcon } from '@heroicons/vue/24/outline'
import {CloudArrowDownIcon} from '@heroicons/vue/24/outline'
const router = useRouter()
const state = reactive({
Expand Down Expand Up @@ -92,7 +92,7 @@ const exportProducts = async () => {
const fileName = res.data.fileName
const downloadLink = document.createElement('a')
downloadLink.href = `http://localhost:3000/exports/${fileName}`
downloadLink.href = `${import.meta.env.VITE_HOST_API}/exports/${fileName}`
downloadLink.download = fileName
document.body.appendChild(downloadLink)
downloadLink.click()
Expand Down
8 changes: 4 additions & 4 deletions dashboard/src/views/users/UsersView.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script setup lang="ts">
import AuthenticatedLayout from '@/layouts/AuthenticatedLayout.vue'
import axiosInstance from '@/utils/axiosInstance'
import { onMounted, onUnmounted, reactive } from 'vue'
import {onMounted, onUnmounted, reactive} from 'vue'
import OTable from '@/components/OTable.vue'
import { useRouter } from 'vue-router'
import {useRouter} from 'vue-router'
import OModal from '@/components/OModal.vue'
import UsersSidebarForm from '@/views/users/UsersSidebarForm.vue'
import { CloudArrowDownIcon } from '@heroicons/vue/24/outline'
import {CloudArrowDownIcon} from '@heroicons/vue/24/outline'
const router = useRouter()
const state = reactive({
Expand Down Expand Up @@ -53,7 +53,7 @@ const exportUsers = async () => {
const fileName = res.data.fileName
const downloadLink = document.createElement('a')
downloadLink.href = `http://localhost:3000/exports/${fileName}`
downloadLink.href = `${import.meta.env.VITE_HOST_API}/exports/${fileName}`
downloadLink.download = fileName
document.body.appendChild(downloadLink)
downloadLink.click()
Expand Down

0 comments on commit 6c11fbf

Please sign in to comment.