fix: headers missing

This commit is contained in:
Robert Soriano
2022-05-23 10:04:06 -07:00
parent 6dcb4ce8a6
commit 77325a6699
5 changed files with 72 additions and 14 deletions

18
src/runtime/plugin.ts Normal file
View File

@@ -0,0 +1,18 @@
import * as trpc from '@trpc/client'
import { defineNuxtPlugin, useRequestHeaders } from '#app'
import type { router } from '~/server/trpc'
const options = JSON.parse('<%= JSON.stringify(options) %>')
export default defineNuxtPlugin(() => {
const client = trpc.createTRPCClient<typeof router>({
url: options.url as string,
headers: useRequestHeaders(),
})
return {
provide: {
client,
},
}
})