Skip to content

Magewire Request 404 Error

If all Ajax requests to the Magewire controller return a 404 HTTP response on a staging environment, the reason most likely are conflicting PHP session cookies.

This can happen if there is one store using the main topo-level domain name and another store (the staging environment), that uses a subdomain.

For example, if the main store is running on test.com, and the staging environment is on staging.test.com, then the two PHPSESSID cookies exist.
one from the main store with the domain test.com and one from the store with the subdomain.

This causes PHP to lose the session during the Magewire POST requests.
The checkout step configuration is not present in the PHP process session. This means the Magewire checkout component is unknown, leading to the 404 error response.

To fix this issue, the cookie for the main store without the subdomain needs to be deleted, and the checkout session on the subdomain needs to be recreated.

In order to permanently avoid the issue, change the main store to use a subdomain, too, for example, www.test.com instead of test.com.
Then the session cookies for both sites use a subdomain and do not conflict.
Alternatively, change the staging environment to use a different top-level domain.

Another possible option was provided by the developers of the Blackbird agency.
By using the blackbird/cookie-domain-cleaner extension, parent domain cookies are removed automatically.

Please see github.com/blackbird-agency/cookie-domain-cleaner for more information.