mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
## Problem `pnpm audit` reports a moderate advisory for `nuxt` (patched in `>=4.6.2`). The lockfile resolves `nuxt` to 4.5.2 for `blocks/vue`. ## Solution - Ran `pnpm tsx scripts/fix-audit-vulnerability.ts nuxt --json`. It resolved `nuxt` from 4.5.2 to 4.6.3 without a permanent override (`pnpm-lock.yaml` only). The other lockfile changes are the transitive re-resolutions that come with the nuxt upgrade. - nuxt 4.6 types `useRequestEvent()` through `ServerTypes`, which `@nuxt/nitro-server` augments inside a Nuxt app. `blocks/vue` is not a Nuxt app, so the call resolved to the generic `RequestEvent`, and `@supabase/vue-blocks` failed typecheck where it passes that value to `createSupabaseServerClient(event: H3Event | undefined)`. The nuxtjs `is-authenticated` middleware now casts the event to h3's `H3Event`. Under Nitro that is its runtime type, so the block works the same in user apps. - Regenerated `apps/ui-library/public/r/supabase-client-nuxtjs.json` with `pnpm build:registry`. ## Review instructions 1. `pnpm install --frozen-lockfile` succeeds. 2. `pnpm audit --json` lists no advisory for `nuxt`. 3. `pnpm turbo run typecheck --filter='...[origin/master]'` passes (17/17 tasks, including `@supabase/vue-blocks`). 4. `pnpm turbo run lint --filter='[origin/master]'` passes. 5. On the UI library preview, the Supabase client for Nuxt.js block shows the updated `is-authenticated.ts` middleware with the `H3Event` cast. Verification: ran all of the commands above, plus Prettier on the changed files. The first studio typecheck run was killed for running out of memory (exit 137). Rerun with turbo concurrency 1, it passed. ## Checklist - [ ] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) [FE-4886](https://linear.app/supabase/issue/FE-4886/bump-a-single-vulnerable-dependency) --------- Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
42 lines
3.4 KiB
JSON
42 lines
3.4 KiB
JSON
{
|
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
"name": "supabase-client-nuxtjs",
|
|
"title": "Supabase Client for Nuxt.js",
|
|
"description": "",
|
|
"dependencies": [
|
|
"@supabase/ssr@latest",
|
|
"@supabase/supabase-js@latest"
|
|
],
|
|
"registryDependencies": [],
|
|
"files": [
|
|
{
|
|
"path": "lib/supabase/client.ts",
|
|
"content": "import { createBrowserClient } from '@supabase/ssr'\n\nexport function createClient() {\n return createBrowserClient(\n process.env.NUXT_PUBLIC_SUPABASE_URL!,\n process.env.NUXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!\n )\n}\n",
|
|
"type": "registry:lib"
|
|
},
|
|
{
|
|
"path": "registry/default/clients/nuxtjs/server/middleware/is-authenticated.ts",
|
|
"content": "import type { H3Event } from 'h3'\nimport { defineNuxtRouteMiddleware, navigateTo, useRequestEvent } from 'nuxt/app'\n\nimport { createSupabaseServerClient } from '../supabase/client'\n\nexport default defineNuxtRouteMiddleware(async (to) => {\n // Nuxt's Nitro server provides an h3 `H3Event` here\n const event = useRequestEvent() as H3Event | undefined\n\n // create Supabase SSR client directly here\n const supabase = createSupabaseServerClient(event)\n\n // check current user\n const {\n data: { user },\n } = await supabase.auth.getUser()\n\n if (!user && to.path !== '/login') {\n return navigateTo('/login')\n }\n})\n",
|
|
"type": "registry:file",
|
|
"target": "server/middleware/is-authenticated.ts"
|
|
},
|
|
{
|
|
"path": "registry/default/clients/nuxtjs/server/api/profile.get.ts",
|
|
"content": "import { createError, defineEventHandler } from 'h3'\n\nimport { createSupabaseServerClient } from '../supabase/client'\n\nexport default defineEventHandler(async (event) => {\n // Create Supabase SSR client\n const supabase = createSupabaseServerClient(event)\n\n // Example: get user session\n const {\n data: { user },\n } = await supabase.auth.getUser()\n\n if (!user) {\n return { error: 'Not authenticated' }\n }\n\n // Fetch profile row\n const { data, error } = await supabase.from('profiles').select('*').eq('id', user.id).single()\n\n if (error) {\n throw createError({ statusCode: 500, statusMessage: error.message })\n }\n\n return { profile: data }\n})\n",
|
|
"type": "registry:file",
|
|
"target": "server/api/profile.get.ts"
|
|
},
|
|
{
|
|
"path": "registry/default/clients/nuxtjs/server/supabase/client.ts",
|
|
"content": "import { createServerClient } from '@supabase/ssr'\nimport { deleteCookie, EventHandlerRequest, getCookie, H3Event, setCookie } from 'h3'\n\nexport const createSupabaseServerClient = (event: H3Event<EventHandlerRequest> | undefined) => {\n return createServerClient(\n process.env.NUXT_PUBLIC_SUPABASE_URL!,\n process.env.NUXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,\n {\n cookies: {\n get: (key) => getCookie(event!, key),\n set: (key, value, options) => setCookie(event!, key, value, options),\n remove: (key, options) => deleteCookie(event!, key, options),\n },\n }\n )\n}\n",
|
|
"type": "registry:file",
|
|
"target": "server/supabase/client.ts"
|
|
}
|
|
],
|
|
"envVars": {
|
|
"NUXT_PUBLIC_SUPABASE_URL": "",
|
|
"NUXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY": ""
|
|
},
|
|
"docs": "You'll need to set the following environment variables in your project: `NUXT_PUBLIC_SUPABASE_URL` and `NUXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY`.",
|
|
"type": "registry:lib"
|
|
} |