How to Properly Protect your tRPC Routes with Middleware!

Поділитися
Вставка
  • Опубліковано 25 гру 2024

КОМЕНТАРІ • 8

  • @codernerd7076
    @codernerd7076 Рік тому +3

    Keep the trpc content going please! 👌

  • @LEDsellers
    @LEDsellers Рік тому

    This method protects data from an unauthorized user but it doesn't prevent the user from accessing the page. How do you solve that?

    • @merveillevaneck5906
      @merveillevaneck5906 Рік тому

      you would have to set your jwt as a http only cookie at login time but if you have cookies set against "/" with an expiry time then next will have access to it when the page fetches. so you should have the ability to use a utility function in your page code to redirect if the token does not exist. (either in server side props for page router OR in server component for app dir(next13))

  • @homiecoder
    @homiecoder Рік тому +2

    Another banger! Ty gotta keep them trpc route burglars away lol!

  • @27sosite73
    @27sosite73 Рік тому

    thank you