How to propagate context from client to server #720
-
I'm a wayward backend engineer about to reveal my profound ignorance of all things web here, so I apologize in advance for the rambling and dumb questions. I also really appreciate all the documentation and examples in The thrust of what I'm trying to do is simply to have a user's information available to me on the server side after they've logged in on the client. I've read the Authentication section in the docs, where I see we have a custom express server, which pulls headers out of the incoming request and authenticates the user that way, but it's not clear to me how to set those headers appropriately from the client. Fore more context than you probably need or want: I have an existing, separate REST API, which handles user management/auth among other things. I also fetch content from a separate CMS. I'm writing a web app using Vue.js + Vite + Vercel. I had initially written this as an SPA, but I've been trying to move to server-side rendering because
When I was going the SPA route, I had a login page where the user authenticates with my API from the browser, and then I'd been storing some user information and the token returned from the API in a Pinia store backed by I'd also be interested in hearing if you think this whole approach is just dumb, and there's some better/easier way to do it. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Usually, you'd create a new Express.js route |
Beta Was this translation helpful? Give feedback.
Usually, you'd create a new Express.js route
/login
that sets the headers accordingly. (Or use an RPC tool, see https://vite-plugin-ssr.com/api-routes.) Does that answer your question?