Getting Cross-Origin Read Blocking (CORB) blocked cross-origin response with MIME type text/html when serving ReactJS app

混江龙づ霸主 提交于 2019-12-11 15:14:41

问题


I have a Wordpress test site that reverse proxy to a reactjs app. However, a blank page is served and I see Cross-Origin Read Blocking (CORB) blocked cross-origin response with MIME type text/html on the console.

When I add a plain "Hello, World!" in public/index.html, the Hello World is shown but the rest of the page is not shown.

EDIT: To explain further, my wordpress site has a subfolder that serves reactjs app.

My reactjs app is: http://dspstaging.drwealth.com My test wordpress site is: http://35.240.238.94 My url that serves the reactjs app is : http://35.240.238.94/datastaging

As you can see, http://dspstaging.drwealth.com works well, however, when I try to access via http://35.240.238.94/datastaging, only "Hello World" is shown, and console displays a CORB warning.


回答1:


Figured it out. Due to the reverse proxy, the browser was looking for the ReactJS app's static folder inside the Wordpress site's server instead of the React app server. I get the CORB warning since it was not getting the CSS file that it was expecting.

To fix I had to create another rewrite rule, this time for requests for the folder /static. My .htaccess file now looks something like this:

RewriteEngine On
RewriteRule ^datastaging(.*) http://35.198.238.40/data/$1 [P]
RewriteEngine Off

# Rewrite rule for static folder
RewriteEngine On
RewriteRule ^static(.*) http://35.198.238.40/static/$1 [P]
RewriteEngine Off

Hope this helps someone.



来源:https://stackoverflow.com/questions/55589116/getting-cross-origin-read-blocking-corb-blocked-cross-origin-response-with-mim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!