BuildBot

One Binary, Two Worlds

Auth across the boundary

Lesson 4 of 5

An HttpOnly SameSite session cookie beats a localStorage bearer token for a same-origin SPA, Go middleware wraps only the routes that need it, and the fetch helper turns 401 into "go log in".

What you'll learn

  • Choose between a session cookie and a bearer token for a same-origin SPA
  • Write Go auth middleware and wrap individual ServeMux routes with it
  • Handle 401 centrally in the SPA's fetch helper
Members only

A free account unlocks this lesson and every other one.

Runnable challenges, knowledge checks, and progress that syncs across your devices. No card needed.

Not sure yet? Try the free lesson first: The shape of the app