You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How would one go about performing an authenticated backend request using the ssr feature for pages? It seems that this would be impossible without access to cookies or other request headers.
Below is an example of a possible additional parameter to the props function. Am I off base here?
importReactfrom'https://esm.sh/react'importtype{SSROptions}from'https://deno.land/x/aleph/types.d.ts'exportconstssr: SSROptions={props: async(router,request)=>{const{ blogPostID }=router.params;// This is an example of how an access token or any other value could// Be pulled from a request object (via cookies, headers, etc)constaccessToken=getAccessTokenFromRequest(request);constresponse=awaitfetch(`/api/blogPosts/${blogPostID}`,{headers: {"x-access-token": accessToken}});constblogPost=awaitresponse.json();return{
blogPost,};},paths: async()=>{return[]}}exportdefaultfunctionPage(props){return(<p>Title: {props.blogPost.title}</p>)}
The text was updated successfully, but these errors were encountered:
How would one go about performing an authenticated backend request using the
ssr
feature for pages? It seems that this would be impossible without access to cookies or other request headers.Below is an example of a possible additional parameter to the
props
function. Am I off base here?The text was updated successfully, but these errors were encountered: