问题
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