| 1234567891011121314151617181920212223242526 |
- import {defineNuxtPlugin} from "nuxt/app";
- import {useProfileAccessStore} from "~/store/profile/access";
- export default defineNuxtPlugin(async ({$pinia, ssrContext}) => {
- const profileAccessStore = useProfileAccessStore($pinia)
- const arraysCookies = ssrContext?.req?.headers.cookie?.split('; ').map((a:string) => a.split('='))
- if(arraysCookies) {
- const cookies = Object.fromEntries(arraysCookies)
- profileAccessStore.$patch({
- bearer: cookies['BEARER'],
- id: cookies['AccessId']
- })
- const data = await $fetch('/api/my_profile', {
- baseURL: 'http://nginx_new',
- headers: {
- 'x-accessid' : profileAccessStore.id,
- 'Authorization' : 'BEARER ' + profileAccessStore.bearer
- }
- })
- profileAccessStore.setProfile(data)
- }
- })
|