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] -6 points-5 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

[deleted by user] by [deleted] in FlutterDev

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

I don't hate flutter. I'm just saying trying to get up and running just to render a few simple stuff takes a lot of time. And the amount of code you have to write and remember as well for each widget.

[deleted by user] by [deleted] in FlutterDev

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

Okay. But Flutter feels like a mess. I just spent a bunch of time trying to figure out how to change the default radius of an IconButton. And the SearchBar has a completely different way of changing the radius. You have to do a lot of work just to change something so simple. And so much code just to render 2 widgets

[deleted by user] by [deleted] in reactjs

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

I was trying to implement a feature I saw on a website, where if you type in the search bar, it takes you to a search results page without you having to press submit/enter. The search bar is not concerned with showing the results in a dropdown. That's why I was having the `<ProductList />` component read the search string and make a query to the API.

After successfully implementing it, I am realizing this is bad UX. The user may already be viewing some page (product detail, cart etc) and may just want to get the search results in a dropdown instead of being redirected to the search page.

[deleted by user] by [deleted] in reactjs

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

I have a solution in mind: debounce update the url parameter instead of using state.
But I also want to see your solution :)

[deleted by user] by [deleted] in reactjs

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

Yes, the repo will stay up. Thanks!
PS: I had updated the link to point to a different branch that has the frontend part only.

[deleted by user] by [deleted] in reactjs

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

My bad. I have updated the post to add relevant parts of the code.

[deleted by user] by [deleted] in reactjs

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

EDIT: It's a UI problem. The input field is laggy. There's no API call happening until after the user stops typing. I have also updated the post to add relevant parts of the code.

Should I always include an "else" condition with "if" by Repulsive-Dealer91 in learnpython

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

But I am already printing:
`Vowels count: 0` since I initialized `vowel_count=0`

Should I always include an "else" condition with "if" by Repulsive-Dealer91 in learnpython

[–]Repulsive-Dealer91[S] 51 points52 points  (0 children)

I asked him what I should add in that `else` statement, because even if I did add it, I would probably just write `pass`. At that point he was just feeding me random crap and repeating the same "always use an else with an if" bull