qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[🐞] Supbase server client is not working with email provider auth.

Open diecodev opened this issue 2 years ago • 2 comments

Which component is affected?

Qwik Runtime

Describe the bug

I have the next code:

// routes/layout.tsx
import { createServerClient } from "supabase-auth-helpers-qwik";
import type { RequestEventAction, RequestEventBase } from "@builder.io/qwik-city";

const createDB = (requestEv: RequestEventAction | RequestEventBase) => {
  return createServerClient(
    requestEv.env.get("SUPABASE_URL")!,
    requestEv.env.get("SUPABASE_ANON_KEY")!,
    requestEv
  );
};

export const useSigIn = routeAction$(
  async (user, requestEv) => {
    const db = createDBClient({
      supabaseKey: requestEv.env.get("SUPABASE_ANON_KEY")!,
      supabaseUrl: requestEv.env.get("SUPABASE_URL")!,
    });

    const { data, error } = await db.auth.signInWithPassword({
      email: user.email,
      password: user.password,
    });

    console.log({ data });

    return { error: error?.message };
  },
  zod$({
    email: z.string().trim().email(),
    password: z.string().min(8).max(20),
  })
);

When I run the code, the following error shows up in the console:

 [vite] Internal server error: The "host" request header is not available

Reproduction

https://stackblitz.com/edit/qwik-starter-gryzwc?file=src/routes/layout.tsx

Steps to reproduce

follow the supabase integration with qwik in this oficial docs and create a serverClient and try to auth with signInWithPassword method.

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12450H
    Memory: 424.02 MB / 7.73 GB
  Binaries:
    Node: 18.15.0 - ~\AppData\Local\fnm_multishells\51860_1683645800971\node.EXE
    npm: 9.5.0 - ~\AppData\Local\fnm_multishells\51860_1683645800971\npm.CMD
  Browsers:
    Edge: Spartan (44.22621.1555.0), Chromium (113.0.1774.35)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @builder.io/qwik: 1.0.0 => 1.0.0
    @builder.io/qwik-city: ^1.0.0 => 1.0.0
    undici: 5.22.0 => 5.22.0
    vite: 4.3.3 => 4.3.3

Additional Information

No response

diecodev avatar May 09 '23 16:05 diecodev

fixed in #4185

aivarsliepa avatar May 13 '23 09:05 aivarsliepa

Should be fixed, update to the latest supabase helper!

manucorporat avatar May 14 '23 14:05 manucorporat