JsonAPI bulk order autosuggest request leads to 404

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

JsonAPI bulk order autosuggest request leads to 404

Post by boettner » 20 Jul 2023, 14:05

Hi all,

on TYPO 11.5.29 and Aimeos 22.10.7 the following GET request leads to a 404 when trying to add a product via the bulk order form
https://dev.domain.com/jsonapi?ai[actio ... &ai[filter][||][0][=~][product.code]=99000009580&ai[filter][||][1][%3E][index.text:relevance(%22en%22,%2299000009580%22)]=0&ai[include]=attribute,text,price,product

Whereas the https://dev.domain.com/jsonapi?ai%5Bcontroller%5D=Url OPTIONS request for retrieving the resources works. So the basic routing configuration should be ok.

I will be able to upgrade to 23.7 in the near future but maybe I can backport something in case this should be a bug.

Best
Robert.

User avatar
aimeos
Administrator
Posts: 7895
Joined: 01 Jan 1970, 00:00

Re: JsonAPI bulk order autosuggest request leads to 404

Post by aimeos » 21 Jul 2023, 10:14

There seems to be a problem in TYPO3 setups only. In the Laravel demo it's working, in the TYPO3 demo not.
According to the JS error in the browser console, there's no valid JSON:API URL available for the (product) resource but the only difference seems to be that in TYPO3 the domain is missing in the OPTIONS response:

TYPO3 JSON:API OPTIONS response:

Code: Select all

product: "/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=product"
Laravel JSON:API OPTIONS response:

Code: Select all

product: "https://laravel.demo.aimeos.org/jsonapi/product"
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: JsonAPI bulk order autosuggest request leads to 404

Post by boettner » 21 Jul 2023, 13:15

At least in my setup the OPTIONS request returns an absolute URL scheme:

Code: Select all

"resources": {"attribute":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=attribute",
"basket":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=basket",
"catalog":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=catalog",
"customer":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=customer",
"locale":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=locale",
"order":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=order",
"product":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=product",
"review":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=review",
"site":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=site",
"service":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=service",
"stock":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=stock",
"supplier":"https:\/\/dev.domain.com\/jsonapi?ai%5Baction%5D=options&ai%5Bcontroller%5D=Jsonapi&ai%5Bresource%5D=supplier"}

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: JsonAPI bulk order autosuggest request leads to 404

Post by boettner » 23 Jul 2023, 09:47

A follow up to my quick reply from Friday. I guess it‘s more like TYPO3 classifying it as not routable then. My first guess for a reason would be the nested GET array. I will try to debug that further to find the root cause.

Changing the nested filter array to a single query string might be a solution. Am I right in the assumption that this is all client side anyway?

boettner
Advanced
Posts: 136
Joined: 09 Feb 2015, 17:49

Re: JsonAPI bulk order autosuggest request leads to 404

Post by boettner » 24 Jul 2023, 13:43

Simple solution for all cases in which it does not impose any security risks is setting

Code: Select all

$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFoundOnCHashError'] 
to false.

For other cases one has to deal with TYPO3 routing and define some kind of exclusion or special treatment for the ai[filter] maybe via a PSR-15 request Middleware.

Post Reply