无法从React App提供静态资产

时间:2018-12-22 08:29:03

标签: reactjs nginx react-router

我目前正在尝试在我的nginx配置中配置Rails应用程序以及React应用程序。我的应用程序的名称空间为“ / rp /”。我可以提供索引,但是索引无法加载任何关联的css / js文件。我怀疑我的位置块捕获到/ rp / static的请求是罪魁祸首。由于我不想重新路由任何与Rails相关的资产,因此需要指定此名称。预先感谢!

这是失败请求的屏幕截图

https://imgur.com/yPiVBe4

server {
   listen         80;
   server_name    _;
   root /portal/public;
   passenger_enabled on;
   passenger_min_instances 1;
   passenger_friendly_error_pages off;
   passenger_env_var CDN_PREPEND "http://localhost:3000/";
   if ($http_x_forwarded_proto = 'http') {
       return 301 https://qa.harvestmark.com$request_uri;
   }

   location /rp/static {
    root /portal/public/react_response_pages/build/static;
     try_files $uri $uri/ /portal/public/react_response_pages/build/static;
   }


   location /rp {
     root /portal/public/react_response_pages/build;
     try_files $uri $uri/ /react_response_pages/build/index.html;
   }

}

0 个答案:

没有答案
相关问题