PricingBlog

Are there any sitewide settings in toddle?

  • darren_alderman-1289302336182943786

    Darren

    1 year ago

    Can I add logic somewhere they says on any page in my app, if the authentication fails, send to login?
    And where can I add contents to the header of every page?

    Seems like every page is siloed separately, but I hope I'm wrong!

    More context: https://guides.darrenalderman.com/recordings/i4X7uA9pvziTSn2TYFdc
  • andreasmoller-1289322368807866389

    Andreas Møller

    1 year ago

    Hey there are some setting that can be added site wide such as favicon etc. but most are set on a page level, since most change depending on the page.
  • andreasmoller-1289323768065556500

    Andreas Møller

    1 year ago

    In terms of checking auth, you are on the right path, but you can make it a bit simpler than what you have.

    You dont need to call the APIs on load if you set them to auto-fetch.
    That way APIs specified on pages will also be fetched during SSR for a faster overall load time.

    I don't think you need to save the userid to local storage, since you are fetching the user data anyways. This request can also be auto fetched.

    The way you validate the user has an active session is by calling an API. One way of thinking about it is that it is not the page that is protected, it is the data. If that data cannot be fetched because the user is not authenticated, then you redirect to login.

    We have a few things in the pipeline that will make this easer to replicate across different pages and components. First with our new API V2 that is currently being finished, and later by giving you better tools for controlling the head section of the page.
  • darren_alderman-1289325510941216778

    Darren

    1 year ago

    Nice! That helps - I'll do some testing 😉
  • andreasmoller-1289325932255121480

    Andreas Møller

    1 year ago

    With API V2 we are adding redirect-rules that lets you handle redirects during SSR, so that the user doesn't load the page before being redirected.
  • andreasmoller-1289326244177117248

    Andreas Møller

    1 year ago

    For head items we are thinking that we will actually let you manage the content of the head tag the same way you render normal elements inside the body, that way you can create a reusable component for commonly used scripts and metatags etc.
  • max.kayr-1289423847031963730

    Max

    1 year ago

    Whait, what? 👀
    That would be really cool!
  • andreasmoller-1289672801804095519

    Andreas Møller

    1 year ago

    Yes we have been discussing that idea for a while. The main blocker is that we would have to migrate existing projects which we dont have a great system for yet.
  • Still it is pretty high on the wish list.
  • max.kayr-1289674204442267720

    Max

    1 year ago

    I'm fine with my sites breaking for that feature 😇
  • andreasmoller-1289674287782953011

    Andreas Møller

    1 year ago

    I am not.
  • andreasmoller-1289674590099869707

    Andreas Møller

    1 year ago

    The options are either to have it be only affecting new pages, or to setup a migration so you can automatically update the pages in your project. The latter is probably the best option.
  • 282143925291057163-@Andreas Møller
    I am not.
    max.kayr-1289675871073865779

    Max

    1 year ago

    Thought so 😅
  • andreasmoller-1289675973364813864

    Andreas Møller

    1 year ago

    But it will come.