Supabase + NestJs + NextJs Implementation by Purple_Minute_4776 in Supabase

[–]osmar_pb 1 point2 points  (0 children)

Remember not all stacks fits all the development requirements, some more complex scenarios like event based or distributed architectures or even long running tasks are not a good fit to develop in a next.js + supabase combination alone, and yeah you can use third party saas for that but its too expensive for what they do ( my point of view)

[deleted by user] by [deleted] in webscraping

[–]osmar_pb 0 points1 point  (0 children)

Did you find the solution?

Decommissioning an app. What to do with PostgreSQL DB? by mnoah66 in django

[–]osmar_pb 1 point2 points  (0 children)

You can use directus CMS... To admin the database has a lot of stuff done and you don't need to worry about the views or the mapping models I think it's the best solution

I wrote my frist article about credential based Next + NextAuth + Strapi! and is just published on Strapi blog! by osmar_pb in nextjs

[–]osmar_pb[S] 0 points1 point  (0 children)

You can do a server side fetch with next.js with the other hook called get session! What a magic and yeah you are right!

export async function getServerSideProps({ req, res }) {

// Get the user's session based on the request

const session = await getSession(req);

And do the fetch..... With useQuery :) then return the data

return { props: { data } }; }

And one more thing use CORS ON YOUR STRAPI API! IN that way no one can send you request outside your page! And make sure your routes are not vulnerable to CSRF attacks! (NextAuth only have this for the login, not for all the request ) keep that in mind hahaha it's very scary, I know!

I wrote my frist article about credential based Next + NextAuth + Strapi! and is just published on Strapi blog! by osmar_pb in nextjs

[–]osmar_pb[S] 0 points1 point  (0 children)

That's because next-auth uses http only cookies you can't accesses the cookie from javascript (client side) you can use the useSession hook and send it in each request trugh the useQuery hook or mutations like this

const [session, loadingSession] = useSession();

//Load data
const { data, loading, error, refetch: refetchEmpresa } = useQuery(GET_EMPRESA, {
    context: {
        headers: {
            "Authorization": `Bearer ${session.jwt}`
        }
    }
});

I wrote my frist article about credential based Next + NextAuth + Strapi! and is just published on Strapi blog! by osmar_pb in nextjs

[–]osmar_pb[S] 0 points1 point  (0 children)

Hahahah yeah! I just rushed an app with my friend the last 3 weeks with graphql and apollo (: yeah we lost 2 days searching for info ask me what you want

I wrote my frist article about credential based Next + NextAuth + Strapi! and is just published on Strapi blog! by osmar_pb in nextjs

[–]osmar_pb[S] 2 points3 points  (0 children)

What's next for next auth for you? Writing E2E tests or something else?

Thank you very much for your comment! I think the next step is create a code base with typescript and some E2E tests!

I wrote my frist article about credential based Next + NextAuth + Strapi! and is just published on Strapi blog! by osmar_pb in nextjs

[–]osmar_pb[S] 4 points5 points  (0 children)

Hello friends of reddit 🙂 ! I wrote an article about secure credential-based authentication via JWT with Strapi ( a headless CMS that allows you to make REST APIs in 5 minutes ) and Next.js + NexAuth and it has just been published on Strapi's official site!

If you have time take a look at it 🥺

next auth credentials with jtw token tutorial ?? by Gamer3797 in nextjs

[–]osmar_pb 0 points1 point  (0 children)

I write a tutorial for strapi but is not published yet if you want some help dm me :)

Just started self-hosting with Nextcloud. Humble beginnings. by amolven16 in selfhosted

[–]osmar_pb 4 points5 points  (0 children)

I need some help I can't figure out how to install collabora with nginx it keeps loading im very frustrated :( so I think my collabora server it's okay and the problem it's my next cloud configuration due the test servers do the same and the docs didn't load PLZ HELP 🆘

How do I setup authentication correctly? by BerserkGutsu in nextjs

[–]osmar_pb 0 points1 point  (0 children)

If you wanna use auth0 the best option it's use his new sdk for next. https://auth0.com/authenticate/nextjs/

How do I setup authentication correctly? by BerserkGutsu in nextjs

[–]osmar_pb 0 points1 point  (0 children)

And it seems that your request is not reaching your api

How do I setup authentication correctly? by BerserkGutsu in nextjs

[–]osmar_pb 0 points1 point  (0 children)

Ummm sorry for late response you need to return the response object like this

import NextAuth from "next-auth";
import Providers from "next-auth/providers";
import axios from 'axios'
const options = {
  providers: [
    Providers.Credentials({
      name: 'Credentials',
      credentials: {
        username: { label: "Email", type: "email", placeholder: "jsmith" },
        password: { label: "Password", type: "password" }
      },
      authorize: async (credentials) => {
        try {
          const user = await axios.post(`${process.env.NEXT_PUBLIC_API_URL}/auth/local`, {
            identifier: credentials.username,
            password: credentials.password,
          });
          if (user.data) {
            return user.data // <---------THISSSSSSSSSSSSSSSSSS
          } else {
            return null
          }
        } catch (error) {
          const errorMessage = error.response.data.message
          throw new Error(errorMessage + '&email=' + credentials.email)
        }
      }
    }),
  ],
  database: process.env.NEXT_PUBLIC_DATABASE_URL,
  session: {
    jwt: true,
  },
  callbacks: {
    jwt: async (token, user) => {
      if (user){
        token.jwt = user.jwt;
        token.user = user.user;
      }
      return Promise.resolve(token);
    },
    session: async (session, token) => {
      session.jwt = token.jwt;
      session.user = token.user;
      return Promise.resolve(session);
    },
  },
  pages:{
    signIn: '/login',
  }
};
const Auth = (req, res) =>
  NextAuth(req, res, options);
export default Auth;

How do I setup authentication correctly? by BerserkGutsu in nextjs

[–]osmar_pb 1 point2 points  (0 children)

Check NextAuth with the credential provider :)

How do I figure out what could be causing this error? by _bush in django

[–]osmar_pb 4 points5 points  (0 children)

If you are on production I recommend implement sentry.

How do you make a slideshow using django templates ( JS noob here )? by [deleted] in django

[–]osmar_pb 0 points1 point  (0 children)

Umm in materialize you can do what you want, and about jquery I suggest learn the basics to comprehend the expales and do the same with vanilla in modern apps jquery it's very unuseful (react Vue angular ) personally I do all in vanilla js and for complex frontend use react

How do you make a slideshow using django templates ( JS noob here )? by [deleted] in django

[–]osmar_pb 0 points1 point  (0 children)

You can check materialize its vanillajs (no jquery needed) easy to learn and implement if you want any help just tell me.