在自定义域上部署React App时出现404错误

It seems like I followed all the necessary in the documentation but it keeps giving a 404 Error: "There isn't a GitHub pages here" when I go into https://juliesong.me. I got my custom domain through GoDaddy and configured the DNS like so:

Then I changed my package.json file to have

"homepage": "https://www.juliesong.me",

Added a CNAME file in the root directory containing www.juliesong.me

最后进入GitHub页面中的设置:

我搜索了我的问题,很多人说这可能与React Router有关,因此我进行了编辑以包括一个基本名称:

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { HashRouter as Router } from "react-router-dom";
import * as serviceWorker from './serviceWorker';

const routing = (
  <Router basename={process.env.PUBLIC_URL}>
    <App />
  </Router>
);

ReactDOM.render(routing, document.getElementById('root'));

这是我的App.js:

import React, { Component } from 'react';
import {Route} from 'react-router-dom';
import { withRouter } from 'react-router'
import { GlobalStyles, } from "./util/GlobalStyles";

import Home from './containers/Home'


class App extends Component {

  render() {
    const home = () => <Home />

    return (
      <main>
        <GlobalStyles />
          <React.Fragment>
              <Route exact path="/" component={home} />
          </React.Fragment>
      </main>
    );
  }
}

export default withRouter(App);

如果有人可以在这个问题上提供帮助,那就太好了:)

评论