Proxying requests to server
Last updated
Was this helpful?
Last updated
Was this helpful?
To tell the development server to proxy requests to your Magento 2 server, modify a proxy
field to your package.json
, for example:
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
:
You do not need to import this file anywhere. It is automatically registered when you start the development 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.