Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何在Cloudflare后面的Google存储桶中托管React应用程序?_Reactjs_React Router_Google Cloud Storage_Cloudflare - Fatal编程技术网

Reactjs 如何在Cloudflare后面的Google存储桶中托管React应用程序?

Reactjs 如何在Cloudflare后面的Google存储桶中托管React应用程序?,reactjs,react-router,google-cloud-storage,cloudflare,Reactjs,React Router,Google Cloud Storage,Cloudflare,我有一个小的静态网站,我想部署到谷歌存储桶 我有一个与此类似的路由器.jsx <Route component={App}> <Route path="/" component={AuthenticationFirewall(AccessSecurity(MainPanel), Login)}> <IndexRoute component={Homepage} /> <Route path="/compan

我有一个小的静态网站,我想部署到谷歌存储桶

我有一个与此类似的路由器.jsx

<Route component={App}>            
  <Route path="/" component={AuthenticationFirewall(AccessSecurity(MainPanel), Login)}>
     <IndexRoute component={Homepage} />
     <Route path="/companies" component={Companies}>
       <IndexRoute component={CompaniesTable} />  
       <Route path="/companies/:id" component={CompaniesDetail} />
     </Route> 
  </Route> 
</Route>
正确处理路线

我还希望使用Cloudflare的http代理,因为https,我觉得他们为自定义404错误页面提供服务可能有问题

问题:

  • 如何设置Bucket的Web服务器以正确地为js应用程序路由服务
  • 我需要在Cloudflare的Web服务器部分设置一些内容吗

  • 主要技巧是:

    如果出现404个错误,Google存储桶的Web服务器需要提供index.html

    Cloudflare

    您需要禁用页面规则中名为“智能错误”的功能

    因此,Cloudflare的Web服务器让我们使用Bucket来“正确”处理错误

    详情如下:

    我在cloudflare中找不到“智能错误”规则,但google storage 404页面技巧为我解决了这个问题。这对我仍然不起作用
     location / {
        root /var/www/;
        try_files $uri /index.html;
       }