© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•13mo ago
jbreite

Server Side Requests from a Mobile App that uses Client side Auth

I am building a mobile app that uses a server to make requests. Currenty, it is all built with Expo including API routes. I authenticate people on the client and then send requests through the server. I am using RLS on my tables. I want to be able to send authenticated requests through my server while using client side authentication.

How I'm thinking about it.
1. Before I send a request on the client to the server get the access token from the session.
2. Include the access token in the headers as authorization
3. Send the request

Is this the correct way to do it? Currently, it is not working, but just wanted to make sure that this made sense.

I'm able to get the correct use on the server through this:
  const { data: user, error } = await supabaseServer.auth.getUser(token);
  const { data: user, error } = await supabaseServer.auth.getUser(token);


For example, using the Vercel AI SDKK and trying to send the reequest like this.

  } = useChat({
    fetch: expoFetch as unknown as typeof globalThis.fetch,
    headers: {
      Authorization: `Bearer ${accessToken}`,
      "Content-Type": "application/json",
    },
    api: generateAPIUrl("/api/chat"),
    body: { chatContext, firstTenRecords, userId: user?.id },
    onError: (error) => console.error(error, "ERROR, ", error.message),
    onResponse: (request) => console.log("request", request),
  });
  } = useChat({
    fetch: expoFetch as unknown as typeof globalThis.fetch,
    headers: {
      Authorization: `Bearer ${accessToken}`,
      "Content-Type": "application/json",
    },
    api: generateAPIUrl("/api/chat"),
    body: { chatContext, firstTenRecords, userId: user?.id },
    onError: (error) => console.error(error, "ERROR, ", error.message),
    onResponse: (request) => console.log("request", request),
  });
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Server side auth via the supabase React client
SupabaseSSupabase / help-and-questions
4y ago
Different Supabase URL for client side and server side breaks auth
SupabaseSSupabase / help-and-questions
5mo ago
SvelteKit and Authentication—server- or client-side?
SupabaseSSupabase / help-and-questions
4y ago
Does server-side authentication work in tendom with client-side?
SupabaseSSupabase / help-and-questions
4y ago