@nitra/vite-boot 5.0.9 → 5.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/token.js +10 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nitra/vite-boot",
3
- "version": "5.0.9",
3
+ "version": "5.0.10",
4
4
  "description": "Vite boot",
5
5
  "type": "module",
6
6
  "exports": {
package/src/token.js CHANGED
@@ -120,13 +120,17 @@ export async function refreshToken() {
120
120
  // Якщо запущений аполо
121
121
  // допускаємо що ми всередині прикладення
122
122
  if (globalThis.location.pathname === '/login') {
123
- await defaultLogin(check.decoded, result.token)
123
+ defaultLogin(check.decoded, result.token)
124
124
  } else {
125
- setUser(check.decoded)
126
-
127
- // перезавантажуємо щоб він вступив в дію
128
- // wsClient.restart()
129
- // wsClient.dispose()
125
+ setUser(check.decoded, result.token)
126
+
127
+ // Перезавантажуємо WS, щоб він використовував новий токен
128
+ try {
129
+ const { wsClient } = await import('./apollo.js') // імпорт тільки тут, на логіні не потрібно + уникнення можливих циклічних залежностей зі статичним імпортом
130
+ wsClient.dispose()
131
+ } catch {
132
+ // Якщо apollo недоступний, хоча це не повинно бути, бо ми вже у прикладенні
133
+ }
130
134
  }
131
135
  } catch (error) {
132
136
  console.error('Error:', error)