Proxying requests to server
To tell the development server to proxy requests to your Magento 2 server, modify a proxy
field to your package.json
, for example:
Heads up!
This feature is only supported in development
(when using start
command).
Configuring proxy manually
If the proxy
option is not flexible enough for you, you can get direct access to the Express app instance and hook up your own proxy middleware.
You can use this feature in conjunction with the proxy
property in package.json
, but it is recommended you consolidate all of your logic into src/setupProxy.js
.
First, install http-proxy-middleware
using npm or Yarn:
Next, create src/setupProxy.js
and place the following contents in it:
You can now register proxies as you wish! Here's an example using the above http-proxy-middleware
:
Configuring Magento 2 server
To use Magento 2 as a data source for ScandiPWA, you are required to make sure that it is using the correct Composer dependencies. The list of your application Composer dependencies can be found in your ScandiPWA application's composer.json
file.
You can copy the dependencies defined in require
field of your application's composer.json
to your Magento server's root composer.json
and execute the composer update
command.
Last updated