在 Netlify 中找不到页面

问题描述 投票:0回答:1

我目前正在构建一个 React 网站,我创建了一个 PageNotFound 组件并集成到我的路由上,该组件工作正常,但在 Netlify 上部署时,它显示默认的 netlify 页面未找到,不是我的。

`

    import { Link } from 'react-router-dom'; 
    import errorPage from '../assets/images/pageNotFound.jpg'; 
    import { Button } from '../components';

export const PageNotFound = () => {
  return (
    <main>
      <section className='flex flex-col justify-center px-2'>
        <div className='flex flex-col items-center my-4'>
          <p className='text-7xl text-gray-700 font-bold my-10 dark:text-white'>
            404, Oops!
          </p>
          <div className='max-w-lg'>
            <img className='rounded' src={errorPage} alt='404 page not found' />
          </div>
        </div>
        <div className='flex justify-center my-4'>
          <Link to='/'>
            <Button props='Back to Reel' />
          </Link>
        </div>
      </section>
    </main>
  );
};

`

我需要进行任何设置或 netlify 或什么吗?

reactjs deployment react-router netlify
1个回答
0
投票

您需要通过在公共目录中创建 _redirects 文件并将以下内容添加到其中,将所有请求重定向到 index.html

/* /index.html 200

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.