nextjs -使用 meta刷新重新加载页面给予我404

rdrgkggo  于 2023-05-06  发布在  其他
关注(0)|答案(1)|浏览(210)

我创建了一个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

qcbq4gxm

qcbq4gxm1#

我意识到这条路是错的。登录/login

相关问题