🐛 Fix the authorize page
This commit is contained in:
@@ -9,14 +9,16 @@ export const useSolarNetwork = (withoutProxy = false) => {
|
||||
credentials: "include",
|
||||
// Add Authorization header with Bearer token
|
||||
onRequest: ({ request, options }) => {
|
||||
const side = process.server ? 'SERVER' : 'CLIENT'
|
||||
const side = process.server ? "SERVER" : "CLIENT"
|
||||
console.log(`[useSolarNetwork] onRequest for ${request} on ${side}`)
|
||||
// Get token from user store
|
||||
const userStore = useUserStore()
|
||||
const token = userStore.token
|
||||
|
||||
if (token) {
|
||||
console.log('[useSolarNetwork] Token found, adding Authorization header.')
|
||||
console.log(
|
||||
"[useSolarNetwork] Token found, adding Authorization header."
|
||||
)
|
||||
if (!options.headers) {
|
||||
options.headers = new Headers()
|
||||
}
|
||||
@@ -27,7 +29,9 @@ export const useSolarNetwork = (withoutProxy = false) => {
|
||||
;(options.headers as any)["Authorization"] = `Bearer ${token}`
|
||||
}
|
||||
} else {
|
||||
console.log('[useSolarNetwork] No token found, skipping Authorization header.')
|
||||
console.log(
|
||||
"[useSolarNetwork] No token found, skipping Authorization header."
|
||||
)
|
||||
}
|
||||
|
||||
// Transform request data from camelCase to snake_case
|
||||
@@ -46,5 +50,5 @@ export const useSolarNetwork = (withoutProxy = false) => {
|
||||
|
||||
export const useSolarNetworkUrl = (withoutProxy = false) => {
|
||||
const config = useRuntimeConfig()
|
||||
return (config.public.development && !withoutProxy) ? "/api" : config.public.apiBase
|
||||
return config.public.apiBase
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user