Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions nextjs-example/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { Reactions } from "./components/Reactions";
import { headers } from "next/headers";

const ROOM_ID = "next";

export default async function Home() {
// fetch initial data in server component for server rendering
const roomHost = "example-reactions.jevakallio.partykit.dev";
const roomHost = headers().get("host") + "/partykit";
const roomId = ROOM_ID;
const req = await fetch(`https://${roomHost}/party/${roomId}`, {
const protocol =
roomHost.startsWith("localhost") || roomHost.startsWith("127.0.0.1")
? "http"
: "https";
const req = await fetch(`${protocol}://${roomHost}/party/${roomId}`, {
method: "GET",
next: { revalidate: 0 },
});
Expand Down
16 changes: 14 additions & 2 deletions nextjs-example/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}
const nextConfig = () => {
const rewrites = async () => [
{
source: "/partykit/:path*",
//destination: "http://localhost:1999/:path*",
destination: "https://example-reactions.jevakallio.partykit.dev/:path*",
},
];

module.exports = nextConfig
return {
rewrites,
};
};

module.exports = nextConfig;