Update frontend to use runtime config for laravel api

main
TZGyn 2 years ago
parent 8a4ad503ef
commit 73527c4c32
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -0,0 +1 @@
LARAVEL_API=http://localhost:8000

@ -1,5 +1,7 @@
import type { UseFetchOptions } from 'nuxt/app'
const config = useRuntimeConfig()
const useCustomFetch = async <T>(
path: string,
options: UseFetchOptions<T> = {}
@ -11,7 +13,7 @@ const useCustomFetch = async <T>(
headers['X-XSRF-TOKEN'] = token.value as string
}
return useFetch('http://localhost:8080' + path, {
return useFetch(config.public.laravelApi + path, {
credentials: 'include',
watch: false,
...options,

@ -9,8 +9,7 @@ export default defineNuxtConfig({
},
runtimeConfig: {
public: {
api: 'http://dev.local:8000/api',
url: 'http://dev.local:8000',
laravelApi: process.env.LARAVEL_API || 'http://localhost:8000',
},
},
ssr: false,

Loading…
Cancel
Save