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:

"proxy": "http://localhost:4000",

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:

npm install http-proxy-middleware --save # for NPM
yarn add http-proxy-middleware # for Yarn

Next, create src/setupProxy.js and place the following contents in it:

const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
// ...

You can now register proxies as you wish! Here's an example using the above http-proxy-middleware:

const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
target: 'http://localhost:5000',
changeOrigin: true,

Heads up!

You do not need to import this file anywhere. It is automatically registered when you start the development server.

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.