我创建了一个codesandbox来显示这个问题:https://codesandbox.io/p/sandbox/charming-surf-kmtbib
基本上这是索引页:
index.tsx
import Head from "next/head";
const Home = () => {
return (
<Head>
<meta httpEquiv="refresh" content="0; url=/login" />
</Head>
);
}
export default Home;
注意:我也试过,但也失败了
import { redirect } from 'next/navigation';
const Home = () => redirect('/login/');
export default Home;
pages/login/login.tsx
import Head from "next/head";
import styles from "@/styles/Home.module.css";
export default function Home() {
return (
<>
<Head>
<title>Hello world</title>
</Head>
<main className={styles.main}>
<h1>Hello world</h1>
</main>
</>
);
}
仅转到/login返回404
如何在nextjs的dev模式下加载此页面?也许我可以在next.config.js中配置一些东西,比如webpack devserver historyApiFallback
1条答案
按热度按时间qcbq4gxm1#
我意识到这条路是错的。登录/login