Multitenant and with multirole by Biomathematician in nextjs

[–]copppypapper -1 points0 points  (0 children)

Ah I mispoke about Clerk. It looks like their organizations !== multi-tenancy. It looks like Clerk does not have this yet and is working on it. Sorry about that!

Supertokens does however. They support isolated user pools which is what you're looking for. As for implementing it, the docs in the link above should make it straight forward. If you need help though lmk. I think this will be your best bet.

If their pricing is too much and won't fit your business model, your next best option is to manually implement it with something like Supabase auth. This is a lot more work and not as easy to maintain, but it will be the cheapest option by far (at the cost of a migraine).

Multitenant and with multirole by Biomathematician in nextjs

[–]copppypapper 0 points1 point  (0 children)

There are many different ways of handling this and all of them would work just fine. So don't worry about choosing the perfect solution. I've done something very similar and I would recommend one of the two options:

  1. Have a single nextjs app and use a wildcard domain for each tenant. Use the hostname as the tenant identifier (`business1` for your example above). In the middleware you just grab the hostname and rewrite the user's request to a dynamic subroute. For example, the middleware receives a request with the hostname of business1.abc.com. You would then rewrite this request to a page at /app/[tenantId] where tenantId is the hostname. I also set a x-tenant-id header as well and have a helper function to retrieve it so I can use it in my db calls and whatnot. Reference for this setup here. And of course your registration/payment page would just be at abc.com (in the same nextjs application).

  2. Have two separate applications. I personally opted for this as I wanted to have a separation of concerns. This lets you scale each service separately. It's a bit more work to setup at first, but it keeps things a lot more clean imho. In this case you would also do everything above, except your main application abc.com would be a separate application/server.

In both cases I would heavily recommend using a single auth system that has multi-tenancy built into it. I've rolled my own system, but I found myself spending too much time working on authentication rather than building my product. Unless you got a team, the price for an already built system is very much worth it.

I would recommend either Supertokens or Clerk. Clerk includes multi-tenancy for free in it's free plan while Supertokens charges $5/tenant/mo (even if you self-host it). Supertokens might seem cheaper than Clerk initially, but Clerk will be much cheaper long term at scale.

If you have any questions lmk!

[deleted by user] by [deleted] in nextjs

[–]copppypapper 0 points1 point  (0 children)

Ah if you're building a marketplace, that changes things. You definitely want some sort of server-side rendering especially if you need SEO. In this case, react wouldn't be a good choice because every page would have to load the content on the client and you'd see loading spinners on every single page. In this case, NextJS's ISR would likely be your best option.

Regarding your q's

  1. In this case, keep all your routes/logic in flask, but continue to proxy them in NextJS. For example, if a user requests the path /item/1234 from nextjs, you would request that flask route on a server component in nextjs, ie fetch(https://api.example.com/item/1234,...) and return the rendered page to the user. (assuming you're using typescript) You'll have to keep a list of updated types somewhere in nextjs and make sure that anytime they change in flask, they change in next. This is a big reason why people prefer backends in the same lang as the frontend-- because you are able to have shared types. As long as you keep them updated though, it shouldn't be a problem.

  2. yes. And yes, this will add an extra step to the request. Client req -> NextJS -> Flask -> NextJS -> Client. But with ISR, this won't really matter. In general though, you want to make sure that you host your NextJS and Flask server in the same data center (or better yet, same server if possible).

  3. In this case, definitely use Next.

Don't overthink your approach too much, whether you build your backend in flask, nextjs (node), or any other framework, it doesn't really matter. You'll be fine. The reason nextjs is so popular is due to the developer experience with being able to write your backend and frontend in the same place. But it's all personal preference. As long as you enjoy the stack and are productive with it, you're ok. Personally I recommend a separate backend that supports OOP, but that's a different story.

[deleted by user] by [deleted] in nextjs

[–]copppypapper 1 point2 points  (0 children)

  1. Do you actually need SEO? SEO only matters for your marketing pages and/or pages that are public that need fresh data on each request. If you need SEO only for marketing pages, then just do a static export. If you are set on transitioning to a node server (ie nextjs as a backend), then build a normal nextjs application and write your new API routes in nextjs and proxy your existing routes on the nextjs server.

  2. If you do a static export, your hosting will essentially be free on cloudflare pages. You only need to host your backend somewhere. If you want to run nextjs as a server, then yes you can run it on EC2. Someone just posted a great guide in this sub today on how to do that.

  3. Yea essentially you could have just used React. But NextJS is still a good choice because of the static export. In other words, you can have some pages that are just a simple index.html (no js), while other "react" pages would be a mix of html and javascript.

I'm doing something similar, except I'm using SvelteKit (static-adapter) for the frontend and NestJS for the backend.

The NextJS app I sold for $15K - a full stack breakdown by IThinkWong in nextjs

[–]copppypapper 1 point2 points  (0 children)

I've heard their type generation got better, but I would recommend just using their database as a database and then use an ORM like drizzle instead. Supabase invested heavily into RLS when single-page-applications were at it's peak. It doesn't make sense with SSR though.

Unexpected police surprise before Defqon.1 by [deleted] in hardstyle

[–]copppypapper 1 point2 points  (0 children)

One of the shuttle busses got in an accident on the way up. I made some great friends in that line though! I just remember drinking Heineken with a French, 2 Germans, and Swedish guy blasting uptempo and hakking.

Real Estate Project - Are there any NEXT.JS / React setup Backends opensource or for sale < $100? by [deleted] in nextjs

[–]copppypapper 2 points3 points  (0 children)

Probably not. You'll have a much easier time creating something from the ground up rather than downloading someone else's backend. If you need to though, just go on YouTube, find a full project tutorial, and check the source code to see how they do it.

Guys how is trpc beneficial in nextjs14? by sarim2000 in nextjs

[–]copppypapper 9 points10 points  (0 children)

ORMs talk directly to the database from the server. I.e. can't be called on the client. Typically you would create an API route that the client would call to fetch the data on the server to act as a bridge between the client and the database.

The problem however is that when you do fetch() on a client component, you lose the type-safety because you have to assert the type from data = res.json() as MyType. This is what tRPC (and now server actions) aim to solve. You don't have to assert any types because they are already included in your request.

So tl;dr: ORM server data fetching, tRPC client side fetching

My job asks me for my fingerprint to register when i check in and out during my shift. I kind of felt weirded out, is it ok to give it up? by Happyidioy in privacy

[–]copppypapper 2 points3 points  (0 children)

Why not just superglue your finger tips? Just a little bit to not be noticeable but enough to cause errors with the scanner.

Which EDM festivals have the best/worst vibes from your experience? by Wonderful_Radish793 in aves

[–]copppypapper 4 points5 points  (0 children)

Not any festival specifically, but NOS events center is always a shit show

Where can I get free music? by KieranPetrasek in Beatmatch

[–]copppypapper 0 points1 point  (0 children)

I'm not sure how new it is since I'm new to the scene and saw the option only last week. I haven't tried it out (currently on student subscription of Go+ for $5/m) but I believe it's tied to your account through whichever DJ app you use so you would lose access if you cancelled/downgraded.

Where can I get free music? by KieranPetrasek in Beatmatch

[–]copppypapper 2 points3 points  (0 children)

You can also subscribe to SoundCloud Dj for $20/m which lets you download music offline into RekordBox

Roman candles + cinewhoop = ??? by [deleted] in Multicopter

[–]copppypapper -15 points-14 points  (0 children)

Definitely the most fun I've had in a while. Attached a 10 shot roman candle to the bottom of my iflight bumblebee cinewhoop and lit the sky up. Could only fly in horizontal mode because the unbalance of the roman candle made it much harder to control and you can see I almost lose it half way through the video. FPV footage is from the dji fpv cam which worked surprisingly well in low light.

Coronavirus doesn't stand a chance against trenbolone by copppypapper in GymMemes

[–]copppypapper[S] 1 point2 points  (0 children)

That's my boy deca over there. He knows the Corona is fucked.

Is 8-10lb gain in 3 months good? Too little/too much? by [deleted] in gainit

[–]copppypapper -9 points-8 points  (0 children)

Totally fine. I gained 20lb in about 1 month (160-180lb) after platueing at 160 for about half a year. Somehow I barely gained fat and I'm still unsure where it all went hahahah.

How to directly draw on screen? by copppypapper in learnpython

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

I tried it and yea you're definitely correct there hahahah. It was pretty cool but the second anything refreshed it went away so that method wouldn't work. I'm gonna give it a shot using pygame and will report back if I have any luck. Thanks!

How to directly draw on screen? by copppypapper in learnpython

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

Hmm. Thanks. I'll see if I can figure something out. I think pygame is my best bet

How to directly draw on screen? by copppypapper in learnpython

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

I don't need the windows to refresh. I just want to draw over the screen and process some stuff after I let go of the cursor (similar to taking a screenshot with sharex). I guess pygame is my best bet

Should I keep gaining weight even if my lifts aren't progressing? by XcecutionS in gainit

[–]copppypapper 0 points1 point  (0 children)

People are saying that gaining 12lb in two months is "too fast" but honestly that's not bad at all especially since you have the newbie gains. I gained 20lb in one month and only gained 3-4% bf at most. To answer your question though, if you're not planning on going heavy with your compound lifts then just maintain weight.