Skip to content

Commit

Permalink
Setup config for variables
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-dharti-r committed May 9, 2024
1 parent 3902032 commit f5c3e51
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ 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
- name: Configure AWS Credentials
Expand Down
4 changes: 4 additions & 0 deletions website/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
SUPABASE_URL_VALUE: "Your Supabase Project URL",
SUPABASE_ANON_KEY_VALUE: "Your Supabase Project anon API key",
};
5 changes: 3 additions & 2 deletions website/utils/supabase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createClient } from "@supabase/supabase-js";
import config from "@/config";

export default createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
config.SUPABASE_URL_VALUE,
config.SUPABASE_ANON_KEY_VALUE
);
5 changes: 3 additions & 2 deletions website/utils/supabase/client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createBrowserClient } from "@supabase/ssr";
import config from "@/config";

export const createClient = () =>
createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
config.SUPABASE_URL_VALUE,
config.SUPABASE_ANON_KEY_VALUE
);
5 changes: 3 additions & 2 deletions website/utils/supabase/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createServerClient, type CookieOptions } from "@supabase/ssr";
import { type NextRequest, NextResponse } from "next/server";
import config from "@/config";

export const createClient = (request: NextRequest) => {
// Create an unmodified response
Expand All @@ -10,8 +11,8 @@ export const createClient = (request: NextRequest) => {
});

const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
config.SUPABASE_URL_VALUE,
config.SUPABASE_ANON_KEY_VALUE,
{
cookies: {
get(name: string) {
Expand Down
5 changes: 3 additions & 2 deletions website/utils/supabase/server.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { createServerClient, type CookieOptions } from "@supabase/ssr";
import { cookies } from "next/headers";
import config from "@/config";

export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
config.SUPABASE_URL_VALUE,
config.SUPABASE_ANON_KEY_VALUE,
{
cookies: {
get(name: string) {
Expand Down

0 comments on commit f5c3e51

Please sign in to comment.