Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add instructions for serving scripts over HTTPS #38

Merged
merged 2 commits into from
Oct 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ If the development server is not running, the root `assets-manifest.json` is not
### Fatal Error: Cannot redeclare ReactWPScripts...

If you get an error that you cannot reduplicate a method in the `ReactWPScripts` namespace, the cause is likely that two copies of `loader.php` are present in separate plugins or themes. Switch the copy in the plugin or theme under development to use a different namespace to avoid collision.

### 404 In WordPress When Loading Bundle On HTTPS Site
By default create-react-app's webpack dev server does NOT use HTTPS. If your WordPress site uses HTTPS, you are likely to get a 404 error like `https://localhost:3000/static/js/bundle.js` in WordPress, even though the webpack dev server, when accessed directly works fine.

To fix this, you must enable HTTPS for the webpack server.

0) Create a .env file in your plugin's root directory, if it does not exist.
1) In .env add `HTTPS=true`
2) Stop and restart the dev server.
3) Load the new HTTPS localhost URL in the browser and dismiss any untrusted certificate warnings.

See [this PR](https://github.com/facebook/create-react-app/pull/552) for more information.