Download next.js/test/e2e/basepath/pages/absolute-url-basepath.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 559 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/basepath/pages/absolute-url-basepath.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/e2e/basepath/pages/absolute-url-basepath.js
-
curl -L -o absolute-url-basepath.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/e2e/basepath/pages/absolute-url-basepath.js
559 Bytes
| import React from 'react' | |
| import Link from 'next/link' | |
| import { useRouter } from 'next/router' | |
| export async function getServerSideProps({ query: { port } }) { | |
| if (!port) { | |
| throw new Error('port required') | |
| } | |
| return { props: { port } } | |
| } | |
| export default function Page({ port }) { | |
| const router = useRouter() | |
| return ( | |
| <> | |
| <Link | |
| href={`http://localhost:${port}${router.basePath}/something-else`} | |
| id="absolute-link" | |
| > | |
| http://localhost:{port} | |
| {router.basePath}/something-else | |
| </Link> | |
| </> | |
| ) | |
| } | |