Skip to content

Commit 012f498

Browse files
committed
chore: leverage userProjectToken if available
1 parent aa13911 commit 012f498

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/features.ts

+6
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export async function setupAI(nuxt: Nuxt, hub: HubConfig) {
8686
if (nuxt.options.dev && !hub.remote && hub.projectKey) {
8787
try {
8888
await $fetch<any>(`/api/projects/${hub.projectKey}`, {
89+
method: 'HEAD',
8990
baseURL: hub.url,
9091
headers: {
9192
authorization: `Bearer ${hub.userToken}`
@@ -269,6 +270,11 @@ export async function setupRemote(_nuxt: Nuxt, hub: HubConfig) {
269270
process.exit(1)
270271
})
271272

273+
// Overwrite userToken with userProjectToken
274+
if (project.userProjectToken) {
275+
hub.userToken = project.userProjectToken
276+
}
277+
272278
// Adapt env based on project defined production branch
273279
if (String(hub.remote) === 'true') {
274280
env = (branch === project.productionBranch ? 'production' : 'preview')

src/module.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { Nuxt } from '@nuxt/schema'
99
import { version } from '../package.json'
1010
import { generateWrangler } from './utils/wrangler'
1111
import { setupAI, setupCache, setupAnalytics, setupBlob, setupBrowser, setupOpenAPI, setupDatabase, setupKV, setupVectorize, setupBase, setupRemote, vectorizeRemoteCheck } from './features'
12+
import type { HubConfig } from './features'
1213
import type { ModuleOptions } from './types/module'
1314
import { addBuildHooks } from './utils/build'
1415

@@ -70,7 +71,7 @@ export default defineNuxtModule<ModuleOptions>({
7071
// @ts-expect-error nitro.cloudflare.wrangler is not yet typed
7172
compatibilityFlags: nuxt.options.nitro.cloudflare?.wrangler?.compatibility_flags
7273
}
73-
})
74+
}) as HubConfig
7475
runtimeConfig.hub = hub
7576
// Make sure to tell Nitro to not generate the wrangler.toml file
7677
// @ts-expect-error nitro.cloudflare.wrangler is not yet typed
@@ -109,7 +110,7 @@ export default defineNuxtModule<ModuleOptions>({
109110
hub.cache && setupCache(nuxt)
110111
hub.database && setupDatabase(nuxt)
111112
hub.kv && setupKV(nuxt)
112-
Object.keys(hub.vectorize).length && setupVectorize(nuxt, hub)
113+
Object.keys(hub.vectorize!).length && setupVectorize(nuxt, hub)
113114

114115
// nuxt prepare, stop here
115116
if (nuxt.options._prepare) {

0 commit comments

Comments
 (0)