In a ScandiPWA theme, almost any page you access will be rendered on the frontend in React. However, sometimes you need to access a Magento controller, not the frontend. In fact, as you may know, certain pages, such as admin and graphql already provide direct access to Magento, not the ScandiPWA theme.

<aside> ➡️ This is often required for payment methods – e.g. Paypal needs to make an IPN request to the Magento server to confirm payment, and Klarna needs this to make callbacks.

</aside>

This page describes how you can configure the router to allow access to certain Magento pages.

How to configure the router?

The ScandiPWA\\Router\\Controller\\ConfigurableRouter class is responsible for determining which routes to send directly to Magento.

To customize it, create a module with a di.xml file and add an item to the ignoredURLs argument with a custom rule.

For example, to allow requests that match ^/paypal/ipn.*, you'd need to add this configuration to your di.xml file:

<config xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>">
		<virtualType name="ScandiPWA\\Router\\Controller\\ConfigurableRouter">
		   <arguments>
		       <argument name="ignoredURLs" xsi:type="array">
		           <item name="ipn" xsi:type="string">^/paypal/ipn.*</item>
		       </argument>
		   </arguments>
		</virtualType>
</config>

This will make sure that URLs similar to: http://someurl.com/paypal/ipn will not be handled by the ScandiPWA controller, rather it should be handled by your or module’s controller.

What syntax is available?

The arguments are expressed in PHP Regex, and will be processed using the preg_match function.

Here are some potentially useful regex expressions for matching URLs:

Symbol Match
^ start of the string
$ end of the string
. any character
.* any number of characters

<aside> ➡️ Many other characters have special meanings (such as ()[]|) so you need to escape them (e.g. \\[ for [).

</aside>

<aside> ℹ️ You can find the full PHP regex documentation here:

PHP: PCRE regex syntax - Manual

</aside>

What are the real examples of this?

In this example with Amazon Payfort, several default controllers have been exposed to the router to achieve proper functioning of the payment flow.