yaviscoke
yaviscoke
Explore posts from servers
TTCTheo's Typesafe Cult
Created by yaviscoke on 12/14/2023 in #questions
tRPC query has any type
I'm using turbo repo for trpc (with express) and react-native, I made mutation query, but in client side when I try to use trpc it has any type on queries @/api/auth
export const auth = publicProcedure
.input(
z.object({
token: z.string(),
provider: z.enum(["google", "apple", "spotify"]),
})
)
// ...
export const auth = publicProcedure
.input(
z.object({
token: z.string(),
provider: z.enum(["google", "apple", "spotify"]),
})
)
// ...
server.ts
import { createTRPCRouter } from ".";
import { auth } from "@/api/auth";

export const appRouter = createTRPCRouter({ auth });

export type AppRouter = typeof appRouter;
import { createTRPCRouter } from ".";
import { auth } from "@/api/auth";

export const appRouter = createTRPCRouter({ auth });

export type AppRouter = typeof appRouter;
and from index.ts I export AppRouter type client.ts
import { createTRPCReact } from '@trpc/react-query'
import type { AppRouter } from 'backend'

export const api = createTRPCReact<AppRouter>()
import { createTRPCReact } from '@trpc/react-query'
import type { AppRouter } from 'backend'

export const api = createTRPCReact<AppRouter>()
so whenever I use api.auth auth type is any but why?? I don't get it I actually followed t3-app configuration of nextjs
11 replies
TTCTheo's Typesafe Cult
Created by yaviscoke on 11/17/2023 in #questions
Next-auth redirects me on auth/error on signIn()
I'm using app router in nextjs, when I call signIn("google") in localhost, next-auth works pretty well but on production, it redirects me instantly on api/auth/error route this is my app/api/auth/[...next-auth]/route.ts look like
import { env } from "@/env";
import NextAuth, { type NextAuthOptions } from "next-auth";
import GoogleProvider from "next-auth/providers/google";

export const authOptions: NextAuthOptions = {
providers: [
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_SECRET,
}),

],
session: { strategy: "jwt" }
};

const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };
import { env } from "@/env";
import NextAuth, { type NextAuthOptions } from "next-auth";
import GoogleProvider from "next-auth/providers/google";

export const authOptions: NextAuthOptions = {
providers: [
GoogleProvider({
clientId: env.GOOGLE_CLIENT_ID,
clientSecret: env.GOOGLE_SECRET,
}),

],
session: { strategy: "jwt" }
};

const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };
what can be problem? in production I think, env are all good
9 replies
TTCTheo's Typesafe Cult
Created by yaviscoke on 10/8/2023 in #questions
metadata in next-auth
in next-auth is it possible to add metadata for special authrozations?
signIn('google', { metadata: {code: "extra data here"}))
signIn('google', { metadata: {code: "extra data here"}))
and I want to get this metadata in session
callbacks: {
session: async ({ session, token }) => {
console.log(session.metadata.code)

return session
},
callbacks: {
session: async ({ session, token }) => {
console.log(session.metadata.code)

return session
},
it would be nicer if I can get that metadata in createUser
2 replies
TTCTheo's Typesafe Cult
Created by yaviscoke on 8/28/2023 in #questions
get user ip in trpc
I know https://www.answeroverflow.com/m/1097080265928609802 in here the question is already answered but i get value in ip as ::ffff:127.0.0.1 this instead of real ip here is how I do that
export const createTRPCContext = async (opts: CreateNextContextOptions) => {
const { req, res } = opts

let ip = req.headers['x-forwarded-for'] as string
const session = await getServerAuthSession({ req, res })

return createInnerTRPCContext({
session,
ip
})
}
export const createTRPCContext = async (opts: CreateNextContextOptions) => {
const { req, res } = opts

let ip = req.headers['x-forwarded-for'] as string
const session = await getServerAuthSession({ req, res })

return createInnerTRPCContext({
session,
ip
})
}
and when I make request I receive in response that ::ffff:127.0.0.1 thats testing response
.mutation(async ({ ctx }) => {
return { success: true, ip: ctx.ip }
})
.mutation(async ({ ctx }) => {
return { success: true, ip: ctx.ip }
})
4 replies
TTCTheo's Typesafe Cult
Created by yaviscoke on 6/29/2023 in #questions
Uploadthing: do not upload immediately
in upload thing is it possible when putting the file in uploader do not upload immediately? i want when I click form button start upload after that not after putting file there
3 replies
TTCTheo's Typesafe Cult
Created by yaviscoke on 4/15/2023 in #questions
Connect Prisma to AWS RDS Database (PostgreSQL)
4 replies
TTCTheo's Typesafe Cult
Created by yaviscoke on 3/13/2023 in #questions
Form Submiting Doesn't Work, It refetches getStaticProps instead
8 replies
TTCTheo's Typesafe Cult
Created by yaviscoke on 2/6/2023 in #questions
Why useQuery runs multiple times?
9 replies
TTCTheo's Typesafe Cult
Created by yaviscoke on 1/31/2023 in #questions
is it problem to install next-auth by hand?
6 replies