xoldyckk
xoldyckk
Explore posts from servers
TTCTheo's Typesafe Cult
Created by xoldyckk on 9/12/2023 in #questions
How to validate the media url returned from clients when using uploadthing?
Client uploads file(s), receives media url(s), sends them to the server , server stores them in database. But what if client submits invalid url(s) that don't correspond to the media files that were uploaded on the client? If the client hijacks the form submission process and provides a custom media url, how do we prevent that?
2 replies
TTCTheo's Typesafe Cult
Created by xoldyckk on 1/6/2023 in #questions
What are different approaches to persisting the state of a page(dynamic pages included)?
On social media sites like instagram, let's say we scroll down a big list of comments and open the profile page for one of the commentors. Now if we navigate back to the comments page again(using back button presumably) the whole page's state is reset, the comments are loaded again(maybe cached), the position on the page we scrolled to(the comment whose commentor's profile we opened) is lost. It would be a hassle to scroll back to that comment again. So, how do apps mitigate this behaviour? I'd like hear about solutions to this which works on dynamic pages as well(like /user/1 and /user/2 both pages have their individual states persisted).
2 replies
TTCTheo's Typesafe Cult
Created by xoldyckk on 1/3/2023 in #questions
How to refetch(refresh) next-auth session manually on the client side?
Let's say the app has two unique models user and profile, both are in a one to one relation. User object will have a field named profileId which can be a string or null depending on whether the user object has a profile linked to it. After a successful sign in we get the user session object back which has profileId === null. Then we force the user to create a profile if they want to make use of all functionalities of the app. So, the user creates a profile which gets linked to their user object in the database. Now session.user.profileId === "somethingId". How do I refresh the session to update this change on client side without any page reloads and stuff? Like doing it the react way, refetch the sesion, set the session state to the refetched value.
7 replies