-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
177630e
commit 9309166
Showing
5 changed files
with
98 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ export type Poll = { | |
title: string; | ||
options: string[]; | ||
votes?: number[]; | ||
ownVote?: number; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"use client"; | ||
|
||
import { signOut, signIn, useSession } from "next-auth/react"; | ||
|
||
export { SessionProvider } from "next-auth/react"; | ||
|
||
export function Session() { | ||
const session = useSession(); | ||
|
||
switch (session.status) { | ||
case "authenticated": | ||
return ( | ||
<button | ||
onClick={() => signOut({ callbackUrl: `${window.location.href}` })} | ||
className="underline text-white text-sm" | ||
> | ||
Sign out | ||
</button> | ||
); | ||
case "unauthenticated": | ||
return ( | ||
<button | ||
className="underline text-white text-sm" | ||
onClick={() => | ||
signIn("github", { callbackUrl: `${window.location.href}` }) | ||
} | ||
> | ||
Sign in with GitHub | ||
</button> | ||
); | ||
default: | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
const PARTYKIT_HOST = process.env.NEXT_PUBLIC_PARTYKIT_HOST || "127.0.0.1:1999"; | ||
const PARTYKIT_PROTOCOL = | ||
PARTYKIT_HOST?.startsWith("localhost") || | ||
PARTYKIT_HOST?.startsWith("127.0.0.1") | ||
? "http" | ||
: "https"; | ||
const PARTYKIT_URL = `${PARTYKIT_PROTOCOL}://${PARTYKIT_HOST}`; | ||
|
||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
experimental: { | ||
serverActions: true, | ||
}, | ||
rewrites: async () => [ | ||
{ | ||
// forward room authentication request to partykit | ||
source: "/session", | ||
destination: PARTYKIT_URL + "/session", | ||
}, | ||
], | ||
}; | ||
|
||
module.exports = nextConfig; |