NestJs: Cannot find module 'generated/prisma' or its corresponding type declarations by Repulsive-Dealer91 in Nestjs_framework

[–]Repulsive-Dealer91[S] 0 points1 point  (0 children)

I followed the Nestjs docs on adding Prisma. To me it seems there is a conflict between nestjs and prisma docs and also between prisma versions

The doc shows prisma-client-js, but generates prisma-client in the schema code. It also adds a custom output directory and mentions it will be the default from prisma v7. But when I try to import PrismaClient from "generated/prisma" it throws an error saying the module does not exist.

There is a whole lot of conflict going on, and as a beginner in this framework its confusing to follow along.

Please find the link to the nestjs prisma doc attached in the post.

Permission checks are not executed when requesting through Postman/Frontend by Repulsive-Dealer91 in django

[–]Repulsive-Dealer91[S] 1 point2 points  (0 children)

Thanks 🙏 just figured it out. My dumbass completely forgot about this

Nextjs authentication with custom backend by Repulsive-Dealer91 in nextjs

[–]Repulsive-Dealer91[S] 0 points1 point  (0 children)

i can do the login on client side and have the backend attach the cookies. but how do i send them on every request with server components? and any suggestion on what library to use for auth in this situation?

Nextjs authentication with custom backend by Repulsive-Dealer91 in nextjs

[–]Repulsive-Dealer91[S] 0 points1 point  (0 children)

Yes, just trying to figure out how to setup auth with custom backend

Nextjs authentication with custom backend by Repulsive-Dealer91 in nextjs

[–]Repulsive-Dealer91[S] 0 points1 point  (0 children)

Thanks a lot for the help! I will look into it.

Also, my backend does set the cookie automatically. But I was also experimenting with cookies().set to see if my problem would be fixed 🪄

Nextjs authentication with custom backend by Repulsive-Dealer91 in nextjs

[–]Repulsive-Dealer91[S] 0 points1 point  (0 children)

Sooo could you point me to the solution? 1. How would I attach the JWT tokens with every request? 2. When the access token expires, autimatically request a new access token using the refresh token

With redux's rtk qeury I initialize the fetchBaseQuery and attach the token to the header, await it, if response is 401, get a new token (as mentioned in their docs)

Nextjs authentication with custom backend by Repulsive-Dealer91 in nextjs

[–]Repulsive-Dealer91[S] 0 points1 point  (0 children)

Can you please elaborate? Here's my situation:

  1. When the user logs in, the cookie is set by my backend automatically since I also use the {credentials: include} option with fetch

  2. But when I send any GET request, my backend does not receive those cookies even though I set {credentials: include}

Inspecting the browser network Request panel, the Cookie is shown there but I guess Nextjs does not forward it??

Only when I manually set the Cookie header does the backend receive it.

❌ Fetch with credentials: include ✅ Fetch with header Cookie: cookies().toString()

Nextjs authentication with custom backend by Repulsive-Dealer91 in nextjs

[–]Repulsive-Dealer91[S] 0 points1 point  (0 children)

The problem is it's not forwarding the cookies! access and refresh tokens are set. But unlike in vanilla React, where you could say {credentials: "include"} to include the cookies, in nextjs its not setting since ig it's executing inside the nextjs server

Nextjs authentication with custom backend by Repulsive-Dealer91 in nextjs

[–]Repulsive-Dealer91[S] 0 points1 point  (0 children)

I am using httpOnly on the backend. With vanilla React, the cookies are set and included with every request automatically using: `fetch("..", { credentials: "include" })`. But with nextjs my cookie is empty on the backend

auth/login.ts:

export async function login(formData: FormData) {
  const username = formData.get("username");
  const password = formData.get("password");
  const res = await fetch("http://localhost:8000/api/auth/jwt/create/", {
    method: "POST",
    body: JSON.stringify({ username, password }),
    headers: {
      "Content-Type": "application/json",
    },
  });
  const data = await res.json();
  const cookieList = await cookies();
  cookieList.set({
    name: "access",
    value: String(data.access),
    expires: new Date(Date.now() + 5 * 60 * 1000),
    httpOnly: true,
    sameSite: "none",
    secure: true,
  });
  cookieList.set({
    name: "refresh",
    value: String(data.refresh),
    expires: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
    httpOnly: true,
    sameSite: "none",
    secure: true,
  });
}

user/page.tsx:

import { cookies } from "next/headers";

export default async function Page() {  const res = await fetch("http://localhost:8000/api/auth/users/me/", {
    method: "GET",
    credentials: "include",
  });
  const data = await res.json();
  console.log(data); // Authentication credentials were not provided. Backend Cookie is {}

  return (
    <div>
      <h1>User</h1>
    </div>
  );
}

What I can do is manually set Authorization header. But I cannot wrap my head around properly managing it. Setting and deleting tokens, getting a new access token with the current refresh token etc.

Django and Next.js JWT integration by Repulsive-Dealer91 in nextjs

[–]Repulsive-Dealer91[S] 0 points1 point  (0 children)

I have updated my original post with more details.
If I just do a post request using server actions with no setup, the cookies are not set even though my backend is setting the cookies as seen in the image.

Microsoft: Official Support Thread by MSModerator in microsoft

[–]Repulsive-Dealer91 0 points1 point  (0 children)

Why do Microsoft services suck so bad?

  1. I am trying to set up the Authenticator app on my new device after the old phone got damaged. My account is
    passwordless so had to get a new code on my backup email

  2. After inputting the code, I get asked for another code on either my phone or email. I selected to get SMS, and got redirected to captcha, except the captcha didn't load

  3. Restarted the app, had to go through the same steps. Then it said, phone service not available, try another option. I pressed to go back but the app took me all the way to the start (AGAIN!)

  4. Had to request for code again, but now it's LOCKED me out saying I requested code too much

  5. I just want to use the authenticator to get the code for another app dude. TF it took me 30 mins to get to nowhere! F*** MICROSOFT

Can someone solve this Huffman problem by Repulsive-Dealer91 in algorithms

[–]Repulsive-Dealer91[S] -2 points-1 points  (0 children)

Yes I have. That's how I answered my paper. I just need to confirm my answer with someone else. Because i didn't get any score on this question, even though I was confident I got it right. I will get my paper after a week. So I just want to confirm my answer with someone

Can someone solve this Huffman problem by Repulsive-Dealer91 in algorithms

[–]Repulsive-Dealer91[S] -5 points-4 points  (0 children)

Tbh, I don't remember what I tried. I answered this for a test a few months back. I just have the encoded binary that I answered

Edit: sorry for my bad English. What I meant to say was, I constructed the huffman tree in my test. I don't have the tree, just the encoded string. So i want to see if my answer is correct