Theo's Typesafe Cult

TTC

Theo's Typesafe Cult

Join the community to ask questions about Theo's Typesafe Cult and get answers from other members.

Join

next js middleware infinite redirect

I have three pages in my app register , login , home if user is not logged he gets redirected to login page , the home page is accessed only if the user is authenticated which is determined if there is a cookie in the browser I wanna implement protected routes via next js middleware scenario : I am having a issue when I login I am redirected to the home page if I go i should be redirected to the home page the previous page is the login page when I do that problem: i get a too many redirects error for a moment then I am redirected to home page as expected I inspected the network tab there is a pattern that goes like this before i am finally redirected to the home page /login page requested (307 temporary redirect) , /home page requested(307 temporary redirect) repeated several times , I also wanna mention that this happens when i am at the login page and try to go to forward and backward pages and get redirected to login since i am not logged in and then login get redirected to home page and try to go back here is the code
``` import { NextRequest, NextResponse } from 'next/server'; export function middleware(request: NextRequest, response: NextResponse) { const isUserLogged = request.cookies.get('chat_accessToken');...

Uploadthing with Next.j, Clerk JWT Convex

hi, I'm creating an application with next.js and convex with clerk's JWT. I'm trying to integrate uploadthing with clerk, I followed the steps in the documentation but I wasn't successful in the part of verifying the user by uploadthing itself using .middleware(() => handleAuth()) //src/app/api/uploadthing/core.ts When I use clerk's JWT with convex, the userId is not captured using auth(), but rather by useUser(), performing the following scheme ...

Vercel function invocations

I have some questions regarding vercel server function invocations. 1. When calling server actions in server components, does this count as a function invocation? 2. When calling the nextjs fetch method to an external api, does this count as a function invocation? 3. When calling the nextjs fetch method but it's a cache hit, does this count as a function invocation?...

Keep page state on navigating back from a product to the product list

I have an e-commerce site which fetches product collections using trpc. I want to be able to keep this page state the same when navigating back, so that the user is back to the previous position they were at. I was thinking there has to be some way to cache the previous page so it does not reload but am not sure where to look. Here is the component in question: ```tsx...

Shadcn Dialog close issue

I am using Inertia with react, there is a checkbox in my dialog if that is checked the dialog should not close, but the inputs should be cleared so the user can keep adding users, but my dialog always closes even if I set the checkbox. I am confused why this does not work....

Invalid Configuration on vercel domain

I have hosted my web app on vercel for nearly a year no with no problems. All of a sudden i have started receiving emails that some of my domains are incorrectly configured. Which i thought was weird because i hadn't changed anything. I contacted support and they said it's because my traffic is proxied through cloudflare. My question is why the sudden change, and has anyone else experienced it?...

Need help making a drizzle query

I have the following schema ```ts export const userTable = createTable("user", { id: int("id", { mode: "number" }).primaryKey({ autoIncrement: true }), ...
Solution:
Forgot to add the relations

Uploadthing Delete Files

Hi, I'm trying to delete lots of files in one go using a cron job... I detect files that are more than 3 days old and delete all of them... I'm doing this: ```js...

tRPC query eating all DB connections upon window refresh

We're building with T3, on one specific page, there are 7 separate query calls. If you tab out of the browser and tab back in, the refetchOnWindow focus will fire all the queries to fetch. This will work fine for the first 2-3 tab in/outs, after which the query will go out, but will never come back(request is just stuck as pending in the network tab) Disabling refetchOnWindowFocus for one specific query seems to help(reduces the occurrence of this bug by about 80%), but it's really weird because it's such a simple query I don't really see how there could be anything wrong with it ```ts...
No description

Create Dynamic Route

Hey team, Any advice on how to create a dynamic route. I'm building an application that uses a hash in the domain extension. Any files that are uploaded on that webpage, I want the route to reflect the hash....

Authentication with Third Party Cookies

Howdy all! My company primarily serves content secured by cookie auth within iframes embedded in the customers pages, like within Sharepoint or Confluence, or Notion. Over the last 12 months, we have had more and more people getting blocked by the third party cookie blocking. Initially, the requestStorageAccess() worked well, but we are quickly seeing that this fails with more people every day. We have about 46k failures now, around 10k users, and that is quickly rising. Something seems to be different with the latest updates to bromium, and I want to make sure we have an auth plan going forward 🙇‍♂️ ...

Slow queries and inserts with postgres

I'm trying out the t3 stack with a neon (I've also tried supabase) postgres database. In both local and prod I get latencies in the 600ms to several second range for very simple queries and inserts. This happens with both Prisma and Drizzle, and is IMO not caused by database location relative to me. I'm kind of at my wits end in terms of debugging. I noticed that cal.com (also using t3) get's queries down to the sub ms range. Does anyone have the faintest idea of what I could try in order to spe...

My upload button receives the presignedUrls from the server but when fetching the url it hangs.

Its odd because the image goes to upload thing and i can see it in my dashboard but the request on my client never recieves a response. Here is my upload button component: ```tsx...
No description

Applying drizzle migrations with Hono

Hi, I'm trying to apply that migrations on the directory like this: ```typescript await migrate(drizzleDb, { migrationsFolder: "./src/databases/tenants/migrations", })...

Data Caching problem in App Router help plz

When I log in with a user who has specific data, that SAME data appears even after logging out and logging in with a different user. Why is this happening? Flow: 1. I'm entering /login and logging in with user A - Opening clients page /clients , viewing data...

UploadButton Error: Cannot read properties of undefined (reading 'match')

I'm following the tutorial and I have an error at https://youtu.be/d5x0JCZbAJs?t=3622 for UploadButton. Any thoughts? Helpful info: I'm using the latest versions of uploadthing:...
No description

allowing certain image formats only

hey, I might be blind, but I can’t seem to find where to allow certain image formats. I can check if the image type is an allowed format, but this still lets the user select the disallowed format. Thank you!

How to make uploadthing work with localhost:3001?

I am building with https://wasp-lang.dev/ which handles API calls by hitting http://localhost:3001, is there a way to hit 3001 via the express & react sdk setup? i can't seem to find a config value to set to make this happen. currently it's hitting 300

UT | Express.js | onUploadComplete doesn't trigger at all

Hi all, this is first time i am trying uploadthing. in my express server i configured it like this: ```js ...

Authorization with External API

Hi all, I'm working on a project that consists of a mobile application in React Native and a desktop application in NextJS. I was hoping to be able to share an API between these two applications, so I've built one in NestJS for this purpose. I am trying to implement auth flow into a NextJS project. Currently, I am facing an issue: When I log in - I'm able to generate an access and refresh token just fine, but once it expires, I have to refresh twice because the refresh call doesn't appear ready in time prior to the API being called from the page component, thus resulting in an unauthorized error....