amp-list index.js:59 Uncaught (in promise) Error: failed fetching JSON data: HTTP error 406​

239 Views Asked by At

In a amp-list element, when I use a json file to load data, for exemple:

src="amp-listing.json", it works fine.

But when I use a json generate from a php script, for exemple: src="amp-listing.php", I have the error:

Uncaught (in promise) Error: failed fetching JSON data: HTTP error 406​​​

at ya (index.js:59)
at yb.g.createError (log.js:344)
at xhr-utils.js:384
at new Promise (<anonymous>)
at qg (xhr-utils.js:378)
at xhr-impl.js:184

I found that the problem is that AMP adds to the json request, the parameter __amp_source_origin=https%3A%2F%2Fwww.yourdomain.com

And the Apache mod_security module doesn't like %2F giving the error:

Not Acceptable! An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.

If I try __amp_source_origin=https://www.yourdomain.com it works properly! But of course, AMP encodes special characters.

Do you have any idea how to fix it?

Thanks!

Pau

1

There are 1 best solutions below

0
On

The solution is to add a rule to mod_security in order to accept the %2F characters in the request URL.