Skip to content

Commit

Permalink
feat: test ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
He1DAr committed Jan 15, 2025
1 parent 2561428 commit 0166205
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
const { withSentryConfig } = require('@sentry/nextjs');

const nextConfig = {
logging: {
fetches: {
fullUrl: true,
},
},
output: 'standalone',
async headers() {
return [
Expand Down
26 changes: 26 additions & 0 deletions src/app/ssr-txid/[txId]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export default async function Page({ params }: { params: Promise<{ txId: string }> }) {
console.log('Fetching data...');
const data = await fetch('https://api.vercel.app/blog', {
next: { revalidate: 20 }, // Revalidate cache every 20 seconds
});

if (data.headers.get('x-nextjs-cache') === 'HIT') {
console.log('Cache hit: serving cached data.');
} else {
console.log('Cache miss: making a new request.');
}

const posts = await data.json();
const txId = (await params).txId;

return (
<>
{txId}
<ul>
{posts.map(post => (
<li key={post.id}>{post.title}</li>
))}
</ul>
</>
);
}

0 comments on commit 0166205

Please sign in to comment.