This file contains hidden or 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
| export default { | |
| fetch(req) { | |
| const url = new URL(req.url); | |
| if (url.pathname === "/sse-test") { | |
| let intervalId: ReturnType<typeof setInterval>; | |
| req.signal.addEventListener("abort", () => { | |
| console.log("Request aborted!"); | |
| }); |
This file contains hidden or 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
| // app/sse/page.tsx | |
| 'use client'; | |
| import { useState, useEffect, useRef } from 'react'; | |
| export default function SSEDemo() { | |
| const [isConnected, setIsConnected] = useState(false); | |
| const [messages, setMessages] = useState<string[]>([]); | |
| const eventSourceRef = useRef<EventSource | null>(null); | |
| const connect = () => { |
This file contains hidden or 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
| // RedirectAction.tsx | |
| import { redirect } from 'next/navigation'; | |
| export default function RedirectAction() { | |
| return ( | |
| <form | |
| action={async () => { | |
| 'use server'; | |
| redirect(`/posts/2`); | |
| }} |
This file contains hidden or 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
| import NextAuth from 'next-auth'; | |
| import Credentials from 'next-auth/providers/credentials'; | |
| const fakeUsers = [ | |
| { | |
| id: '1', | |
| name: 'John Doe', | |
| email: 'john@opennext.com', | |
| }, | |
| ]; |
This file contains hidden or 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
| // search/page.tsx | |
| export default async function Page({ | |
| searchParams, | |
| }: { | |
| searchParams: Promise<{ [key: string]: string | string[] | undefined }> | |
| }) { | |
| const q = (await searchParams).q; | |
| return ( | |
| <> |
This file contains hidden or 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
| import cf from "cloudfront"; | |
| async function handler(event) { | |
| async function routeSite(kvNamespace, metadata) { | |
| const baselessUri = metadata.base | |
| ? event.request.uri.replace(metadata.base, "") | |
| : event.request.uri; |
This file contains hidden or 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
| 'use client' | |
| import { Bug } from 'lucide-react' | |
| import { useState } from 'react' | |
| export const ErrorTrigger = ({ | |
| message = 'An error occurred', | |
| }: { | |
| message?: string | |
| }) => { |
This file contains hidden or 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
| // Next 14.2.24 | |
| 'use client'; | |
| import { Squirrel } from 'lucide-react'; | |
| import { Figtree } from 'next/font/google'; | |
| import { useEffect } from 'react'; | |
| import Logo from '@/components/icons/logo'; | |
| import { Button } from '@/components/ui/button'; | |
| import './(main)/globals.css'; |
This file contains hidden or 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
| test("revalidate should work in GET route handler", async ({ | |
| request, | |
| page, | |
| }) => { | |
| let time = Date.parse( | |
| (await request.get("/methods/get/revalidate").then((res) => res.json())) | |
| .time, | |
| ); | |
| let newTime: number; | |
| let tempTime = time; |
This file contains hidden or 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
| // make `globalThis.after()` available in next 14 | |
| // open-next.config.ts | |
| import type { OpenNextConfig } from '@opennextjs/aws/types/open-next.js'; | |
| const config = { | |
| default: { | |
| override: { | |
| wrapper: () => import('./customWrapper').then((mod) => mod.default), | |
| }, | |
| }, | |
| } as OpenNextConfig; |
NewerOlder