Zach
Zach
NNuxt
Created by Zach on 11/24/2024 in #❓・help
getting Nuxt context into a nitro route
Hey guys, I'm trying to create an adapter for our auth provider, logto, and it's proving to be a bit more difficult than I expected. Originally I was accessing our logto context via nuxtApp.ssrContext?.event.context.logtoClient unfortunately this doesn't work client sided, as you might expect, so I decided to create a nitro route for client requests to go through.
import type LogtoClient from "@logto/node";

export default defineEventHandler(async () => {
const nuxtApp = useNuxtApp();
const logtoClient = nuxtApp.ssrContext?.event.context.logtoClient as LogtoClient
...
import type LogtoClient from "@logto/node";

export default defineEventHandler(async () => {
const nuxtApp = useNuxtApp();
const logtoClient = nuxtApp.ssrContext?.event.context.logtoClient as LogtoClient
...
Unfortunately, I found out I can't access nuxtApp in nitro routes. Does anyone know how I can get that injected context into a nitro route?
9 replies
NNuxt
Created by Zach on 8/15/2024 in #❓・help
self-signed cert gen
hi guys, is there a way to have your server generate a self-signed certificate on startup? i'm trying to set up https for local development so we can test auth0 in dev
6 replies
NNuxt
Created by Zach on 8/9/2024 in #❓・help
defineComponent equivalent
Howdy friends! Sorry for the noob questions, I'm trying to figure out what the defineComponent equivalent is for Nuxt 3. I have this section of code that I'm trying to make work, but I can't quite figure it out. I thought it was defineNuxtComponent, but I believe it is structured a bit differently:
<script lang="ts">
import { createPromiseClient } from '@connectrpc/connect';
import { DynamicContentService } from '~/../gen/proto/summit/v1/dynamiccontent_connect.js';
import { transportKey } from '~~/src/keys';
import type { Tutor } from '~~/gen/proto/summit/v1/dynamiccontent_pb';
import type { PromiseClient, Transport } from "@connectrpc/connect"

interface TutorData {
tutors: Tutor[],
client: PromiseClient<typeof DynamicContentService> | undefined
}

export default defineComponent({
setup() {
const transport = inject<Transport>(transportKey)
if (!transport) {
throw new Error("No transport set by provider")
}
return { transport }
},
data(): TutorData {
return {
tutors: [],
client: undefined
}
},
async mounted() {
// make service client
this.client = createPromiseClient(DynamicContentService, this.transport)

// get tutors from client
this.tutors.push(...(await this.client.listTutors({})).tutors)
}
})
<script lang="ts">
import { createPromiseClient } from '@connectrpc/connect';
import { DynamicContentService } from '~/../gen/proto/summit/v1/dynamiccontent_connect.js';
import { transportKey } from '~~/src/keys';
import type { Tutor } from '~~/gen/proto/summit/v1/dynamiccontent_pb';
import type { PromiseClient, Transport } from "@connectrpc/connect"

interface TutorData {
tutors: Tutor[],
client: PromiseClient<typeof DynamicContentService> | undefined
}

export default defineComponent({
setup() {
const transport = inject<Transport>(transportKey)
if (!transport) {
throw new Error("No transport set by provider")
}
return { transport }
},
data(): TutorData {
return {
tutors: [],
client: undefined
}
},
async mounted() {
// make service client
this.client = createPromiseClient(DynamicContentService, this.transport)

// get tutors from client
this.tutors.push(...(await this.client.listTutors({})).tutors)
}
})
1 replies
NNuxt
Created by Zach on 8/2/2024 in #❓・help
server\api access
No description
3 replies