Børge
Børge
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Børge on 9/25/2024 in #questions
Does anyone know why my animate-pulse is behaving weird?
In the tailwind example https://tailwindcss.com/docs/animation#pulse, it looks like the colors are just fading in and out. But when I try to do it, it seems that the div is just scaling up and down. Does anyone know why?
5 replies
TTCTheo's Typesafe Cult
Created by Børge on 9/5/2024 in #questions
Does anyone have an example repo?
So I read this article, and the data-access-layer section seems pretty interesting: https://nextjs.org/blog/security-nextjs-server-components-actions#data-access-layer I still can't really wrap my head around it, so I was wondering if anyone had an example project, where I could see some more typical use-cases with this data handling model.
3 replies
TTCTheo's Typesafe Cult
Created by Børge on 3/16/2024 in #questions
Streaming Video
Is it possible to stream video from a cloudflare R2 bucket? And if it's possible, is it the right choice?
14 replies
TTCTheo's Typesafe Cult
Created by Børge on 2/11/2024 in #questions
What would this be called?
No description
7 replies
CDCloudflare Developers
Created by Børge on 10/15/2023 in #general-help
Using R2 or Stream & Images
If i want to create an application, where you can upload images and videos. Should i then use R2, or Stream and Images? The videos dosen't have to be streamed, but i still need thumbnails (the first frame of the video).
1 replies
TTCTheo's Typesafe Cult
Created by Børge on 8/28/2023 in #questions
I think somethings really wrong with my tailwind or styles
No description
3 replies
TTCTheo's Typesafe Cult
Created by Børge on 8/20/2023 in #questions
Creating logout as next-auth?
Hey, so I was wondering how I could achieve something like next-auth logout/signout? I have a simple project that just stores a jwt token as a cookie. And I want it to be just like in next-auth, where you log out in one chrome tab, then it automatically logs out in any other open chrome tab. Could anyone explain to me how they achieve this?
11 replies
TTCTheo's Typesafe Cult
Created by Børge on 8/3/2023 in #questions
Cors error
Hello, I keep getting a cors error when trying to logout in my application. Im using nextjs on the frontend, and have a different express backend. I'm pretty new, and cant really tell whether it's coming from the backend or the frontend Frontend: localhost:3000 Backend: localhost:3030 Error:
Access to XMLHttpRequest at 'http://localhost:3000/' (redirected from 'http://localhost:3030/v1/auth/discord/logout') from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Access to XMLHttpRequest at 'http://localhost:3000/' (redirected from 'http://localhost:3030/v1/auth/discord/logout') from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
On the express backend, I have set up cors options like this:
var corsOptions = {
origin: "http://localhost:3000",
credentials: true,
optionSuccessStatus: 200,
};

app.use(cors(corsOptions));
var corsOptions = {
origin: "http://localhost:3000",
credentials: true,
optionSuccessStatus: 200,
};

app.use(cors(corsOptions));
And this is the logout function from the backend:
export async function logout(req: Core.Request, res: Core.Response): Promise<(Core.Response | void | undefined)> {
return res.clearCookie("access_token").redirect("http://localhost:3000")
}
export async function logout(req: Core.Request, res: Core.Response): Promise<(Core.Response | void | undefined)> {
return res.clearCookie("access_token").redirect("http://localhost:3000")
}
Does anyone know how to fix the error?
38 replies
TTCTheo's Typesafe Cult
Created by Børge on 5/11/2023 in #questions
How can i use a random number without getting a hydration error?
Im trying to pass in a random number, but it's giving me a hydration error. How could i do something like this?
const DeveloperPage = ({ users, pages }: Props) => {
return (

<div className="mx-auto px-3 md:px-5 pt-20 pb-11 max-w-screen-xl flex flex-col gap-10">

{/* SEARCH BAR */}
<SearchBar />

{/* USERS */}
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-8 headline-color">
{users.map((user) => (
<UserComponent key={user.id} user={user} randomNumber={Math.floor(Math.random() * (100 - 3) + 3)} /> //HYDRATION ERROR FROM THE RANDOM NUMBER
))}
</div>

<div className="text-white flex items-center justify-center">
{Array.from(Array(pages).keys()).map((page) => (
<Link href={`/udviklere?page=${page + 1}`} key={page}>
{page + 1}
</Link>
))}
</div>
</div>
)
};
const DeveloperPage = ({ users, pages }: Props) => {
return (

<div className="mx-auto px-3 md:px-5 pt-20 pb-11 max-w-screen-xl flex flex-col gap-10">

{/* SEARCH BAR */}
<SearchBar />

{/* USERS */}
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 xl:grid-cols-4 gap-8 headline-color">
{users.map((user) => (
<UserComponent key={user.id} user={user} randomNumber={Math.floor(Math.random() * (100 - 3) + 3)} /> //HYDRATION ERROR FROM THE RANDOM NUMBER
))}
</div>

<div className="text-white flex items-center justify-center">
{Array.from(Array(pages).keys()).map((page) => (
<Link href={`/udviklere?page=${page + 1}`} key={page}>
{page + 1}
</Link>
))}
</div>
</div>
)
};
5 replies
TTCTheo's Typesafe Cult
Created by Børge on 5/3/2023 in #questions
How would I order by the role?
Hello, I'm trying to set up an API, where I return some users. I've got it working, where it returns the right users, with their roles. But I would like to order them so the role "ADMIN" comes first. I know there is orderBy, but every time I use it, it just sends a bunch of errors. Maybe I'm on a completely wrong track? What I'm currently doing to get the user:
const users = await prisma.user.findMany({
skip: skip,
take: perPage,
where: {
role: {
some: {
role: {
in: ["ADMIN", "DEV"]
}
}
}
},
include: {
role: {
where: {
NOT: {
role: 'USER'
},
}
}
}
});
const users = await prisma.user.findMany({
skip: skip,
take: perPage,
where: {
role: {
some: {
role: {
in: ["ADMIN", "DEV"]
}
}
}
},
include: {
role: {
where: {
NOT: {
role: 'USER'
},
}
}
}
});
43 replies
TTCTheo's Typesafe Cult
Created by Børge on 5/2/2023 in #questions
Getting id of user with next-auth
I'm trying to set up next-auth with discord, but I can't get the user ID and discriminator. [..nextauth].ts
export default NextAuth({
adapter: PrismaAdapter(prisma),
providers: [
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET
})
],
callbacks: {

session: async ({ session, user }) => {
console.log("SESSION", session)
console.log("USER", user)


return {
...session,
user: user,
};
},
}
});
export default NextAuth({
adapter: PrismaAdapter(prisma),
providers: [
DiscordProvider({
clientId: process.env.DISCORD_CLIENT_ID,
clientSecret: process.env.DISCORD_CLIENT_SECRET
})
],
callbacks: {

session: async ({ session, user }) => {
console.log("SESSION", session)
console.log("USER", user)


return {
...session,
user: user,
};
},
}
});
This is what it prints out.
SESSION {
user: {
name: 'Børge',
email: '*****@gmail.com',
image: 'https://cdn.discordapp.com/avatars/877175604431171644/11a34f62c10ed43957674fda26e80dcd.png'
},
expires: '2023-06-01T02:45:12.540Z'
}
USER {
id: 'clh5o2occ0000vhqscwd6tfer',
name: 'Børge',
email: '*****@gmail.com',
image: 'https://cdn.discordapp.com/avatars/877175604431171644/11a34f62c10ed43957674fda26e80dcd.png'
},
expires: '2023-06-01T02:45:12.540Z'
}
SESSION {
user: {
name: 'Børge',
email: '*****@gmail.com',
image: 'https://cdn.discordapp.com/avatars/877175604431171644/11a34f62c10ed43957674fda26e80dcd.png'
},
expires: '2023-06-01T02:45:12.540Z'
}
USER {
id: 'clh5o2occ0000vhqscwd6tfer',
name: 'Børge',
email: '*****@gmail.com',
image: 'https://cdn.discordapp.com/avatars/877175604431171644/11a34f62c10ed43957674fda26e80dcd.png'
},
expires: '2023-06-01T02:45:12.540Z'
}
How can i get the user's ID and discriminator?
39 replies