Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-dharti-r committed May 9, 2024
1 parent f5c3e51 commit 93fc031
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ jobs:
run: |
cd website
npm install
sed -i "s|SUPABASE_URL_VALUE|${{ secrets.SUPABASE_URL }}|g" config.js
sed -i "s|SUPABASE_ANON_KEY_VALUE|${{ secrets.SUPABASE_ANON_KEY }}|g" config.js
npm run build
4 changes: 2 additions & 2 deletions website/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
SUPABASE_URL_VALUE: "Your Supabase Project URL",
SUPABASE_ANON_KEY_VALUE: "Your Supabase Project anon API key",
SUPABASE_URL: "SUPABASE_URL_VALUE",
SUPABASE_ANON_KEY: "SUPABASE_ANON_KEY_VALUE",
};
5 changes: 1 addition & 4 deletions website/utils/supabase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { createClient } from "@supabase/supabase-js";
import config from "@/config";

export default createClient(
config.SUPABASE_URL_VALUE,
config.SUPABASE_ANON_KEY_VALUE
);
export default createClient(config.SUPABASE_URL, config.SUPABASE_ANON_KEY);
5 changes: 1 addition & 4 deletions website/utils/supabase/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ import { createBrowserClient } from "@supabase/ssr";
import config from "@/config";

export const createClient = () =>
createBrowserClient(
config.SUPABASE_URL_VALUE,
config.SUPABASE_ANON_KEY_VALUE
);
createBrowserClient(config.SUPABASE_URL, config.SUPABASE_ANON_KEY);
4 changes: 2 additions & 2 deletions website/utils/supabase/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export const createClient = (request: NextRequest) => {
});

const supabase = createServerClient(
config.SUPABASE_URL_VALUE,
config.SUPABASE_ANON_KEY_VALUE,
config.SUPABASE_URL,
config.SUPABASE_ANON_KEY,
{
cookies: {
get(name: string) {
Expand Down
56 changes: 26 additions & 30 deletions website/utils/supabase/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,31 @@ import { cookies } from "next/headers";
import config from "@/config";

export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
return createServerClient(
config.SUPABASE_URL_VALUE,
config.SUPABASE_ANON_KEY_VALUE,
{
cookies: {
get(name: string) {
return cookieStore.get(name)?.value;
},
set(name: string, value: string, options: CookieOptions) {
try {
cookieStore.set({ name, value, ...options });
} catch (error) {
// The `set` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
console.error("Error setting cookie:", error);
}
},
remove(name: string, options: CookieOptions) {
try {
cookieStore.set({ name, value: "", ...options });
} catch (error) {
// The `delete` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
console.error("Error setting cookie:", error);
}
},
return createServerClient(config.SUPABASE_URL, config.SUPABASE_ANON_KEY, {
cookies: {
get(name: string) {
return cookieStore.get(name)?.value;
},
}
);
set(name: string, value: string, options: CookieOptions) {
try {
cookieStore.set({ name, value, ...options });
} catch (error) {
// The `set` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
console.error("Error setting cookie:", error);
}
},
remove(name: string, options: CookieOptions) {
try {
cookieStore.set({ name, value: "", ...options });
} catch (error) {
// The `delete` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
console.error("Error setting cookie:", error);
}
},
},
});
};

0 comments on commit 93fc031

Please sign in to comment.