【问题标题】:How to access the react app by with "url" having "/index.html" at the end?如何通过最后带有“/index.html”的“url”访问反应应用程序?
【发布时间】:2019-10-06 16:26:26
【问题描述】:

我的 react 应用由 EC2 + Docker + Nginx 部署。 我想做的是通过domain/index.html 访问这个网站,但我只能在没有/index.html 的情况下浏览它。我无法弄清楚这是如何工作的......我想如果我通过domain/index.html 访问我的 index.html 文件将被访问并打开我的反应应用程序。有人可以给我一个建议吗?

以下是我的 webpack 配置文件中的一部分。

entry: './src/index.tsx',
output: {
    filename: '[name].[chunkhash].js',
    chunkFilename: '[name].[chunkhash].js',
    path: `${__dirname}/dist`,
    publicPath: '/',
},

【问题讨论】:

    标签: html reactjs webpack


    【解决方案1】:

    我在我的 react-router 中添加了以下行来解决这个问题。我不确定这是不是最好的选择。

    <Route exact path="/index.html" render={() => (<Redirect to="/" />)} />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-24
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多