This is the simplest React app I could come up with to test how proxy-server apps (in general) behave or misbehave within codesandbox.io and stackblitz sandboxes — specifically, proxy server apps that make graphql server calls to bypass an endpoint's CORS policies.
For my use case, this app performs one simple graphql query — to the Venia graphql endpoint https://venia.magento.com/graphql — when a button on the screen is clicked. The app uses a node-based express server to proxy the queries from the UI to Venia's endpoint. Using a server that runs on a different port from the local dev server, effectively bypasses the browser-based CORS policies.
To run the app locally:
- Clone the repo:
git clone [email protected]:commerce-docs/venia-proxy.git
- Change directories:
cd venia-proxy
- Run
yarn
to install dependencies. - Run
yarn dev
to start the project's proxy server and dev server.
You should see a single button at the top of the screen: Fetch Categories from Venia. Click it to fetch the product categories from the Venia graphql endpoint via the proxy server.