@innertia-solutions/innertia-nuxt 0.1.63 → 0.1.65

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.
@@ -37,7 +37,7 @@ export function useEntity() {
37
37
 
38
38
  const list = (params = {}) => useQuery({
39
39
  queryKey: computed(() => ['entities', toValue(params)]),
40
- queryFn: () => api.post('entities', toValue(params)),
40
+ queryFn: () => api.get('entities', { params: toValue(params) }),
41
41
  })
42
42
 
43
43
  const detail = (id) => useQuery({
@@ -6,7 +6,7 @@ export function useRoles() {
6
6
 
7
7
  const list = (params = {}) => useQuery({
8
8
  queryKey: computed(() => ['roles', toValue(params)]),
9
- queryFn: () => api.post('roles', toValue(params)),
9
+ queryFn: () => api.get('roles', { params: toValue(params) }),
10
10
  })
11
11
 
12
12
  const detail = (id) => useQuery({
@@ -6,7 +6,7 @@ export function useUsers() {
6
6
 
7
7
  const list = (params = {}) => useQuery({
8
8
  queryKey: computed(() => ['users', toValue(params)]),
9
- queryFn: () => api.post('users', toValue(params)),
9
+ queryFn: () => api.get('users', { params: toValue(params) }),
10
10
  })
11
11
 
12
12
  const detail = (id) => useQuery({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innertia-solutions/innertia-nuxt",
3
- "version": "0.1.63",
3
+ "version": "0.1.65",
4
4
  "description": "Innertia Solutions — Nuxt layer unificada: core, auth, multitenancy, theme y app contexts",
5
5
  "keywords": [
6
6
  "nuxt",
@@ -0,0 +1,27 @@
1
+ import { defineEventHandler, readBody, createError } from 'h3'
2
+ import { writeSession } from '../../../utils/session'
3
+ import { normalizeLoginResponse } from '../../../utils/login'
4
+
5
+ // Login de plataforma (identidad separada, sin contexto de tenant). Llama a
6
+ // Laravel /platform/auth/login server-to-server; en éxito sella el JWT en la
7
+ // sesión httpOnly (igual que /_auth/login) y devuelve el body SIN token. Es
8
+ // imprescindible que pase por acá y no por el BFF catch-all /api/**, que solo
9
+ // proxea y NO sella la cookie → la sesión nunca quedaría establecida.
10
+ export default defineEventHandler(async (event) => {
11
+ const { email, password } = await readBody(event)
12
+ const config = useRuntimeConfig(event)
13
+ let data: any
14
+ try {
15
+ data = await $fetch(`${config.apiInternalUrl}/platform/auth/login`, {
16
+ method: 'POST',
17
+ body: { email, password },
18
+ headers: { Accept: 'application/json' },
19
+ })
20
+ } catch (err: any) {
21
+ const status = err?.response?.status ?? err?.statusCode ?? 500
22
+ throw createError({ statusCode: status, data: err?.data ?? null, statusMessage: 'login_failed' })
23
+ }
24
+ const { token, body } = normalizeLoginResponse(data)
25
+ await writeSession(event, { token })
26
+ return body
27
+ })