WordPress REST API not working on localhost
I have a WordPress site running WordPress 5.9.3 that is using a React-based theme, which uses the REST API (v1), to retrieve content and menus from the standard WordPress CMS back-end.
However, when trying to install it locally, I can't get the API to work and retrieve the needed data.
I'm using a Docker environment based off this repo: https://github.com/kassambara/wordpress-docker-compose
Since the theme uses React and the REST API to get the site content, trying to view the site gets stuck on the loading screen.
These are the console errors:
GET http://localhost:3000/wp-json/{REDACTED_API_NAME}/v1/site net::ERR_CONNECTION_REFUSED
GET http://localhost:3000/wp-json/{REDACTED_API_NAME}/v1/menus?location=main-menu net::ERR_CONNECTION_REFUSED
GET http://localhost:3000/wp-json/{REDACTED_API_NAME}/v1/menus?location=footer-menu net::ERR_CONNECTION_REFUSED
And here is a stack trace of the first one, for reference if it helps:
(anonymous) @ VM382:1
fetchSiteInformation @ bundle.ea81906….js:2499
fetchInitialContent @ bundle.ea81906….js:2535
(anonymous) @ bundle.ea81906….js:5653
(anonymous) @ bundle.ea81906….js:13750
(anonymous) @ bundle.ea81906….js:12811
componentWillMount @ bundle.ea81906….js:18846
Ng @ bundle.ea81906….js:12158
fi @ bundle.ea81906….js:12197
Rj @ bundle.ea81906….js:12284
Qj @ bundle.ea81906….js:12267
Kj @ bundle.ea81906….js:12267
yj @ bundle.ea81906….js:12260
Ig @ bundle.ea81906….js:12251
bk @ bundle.ea81906….js:12302
(anonymous) @ bundle.ea81906….js:12305
Nj @ bundle.ea81906….js:12261
ik @ bundle.ea81906….js:12305
exports.render @ bundle.ea81906….js:12311
(anonymous) @ bundle.ea81906….js:11350
__webpack_require__ @ bundle.ea81906….js:20
(anonymous) @ bundle.ea81906….js:63
(anonymous) @ bundle.ea81906….js:66
webpack itself compiles with warnings.
The webpack-dev-server is running off port 8081, and phpmyadmin is running off 8080.
I tried to switch the webpack server to use port 3000 instead (to match what the API is calling), but that didn't help.
I can log into WP admin and am having no issues on that side. All content and plugins are present.
This is not an issue on production or UAT environments, nor is it occurring with others on their own local machine.
I'm running Mac Monterey with the Apple M1 chip.