AMP-list for email fail to load sample json

169 Views Asked by At

I'm new to AMP and I'm a creative designer so my knowledge of front-end backend is limited. I trying to do an AMP email which load info from json and display it in the email.

I'm using sample AMP-list component script from https://amp.dev/documentation/components/amp-list/?format=email, everything work fine but when I replace the json link with my sample file it didn't work https://wegoexperience.com/dest.json

Anyone can advice why? Thanks!

1

There are 1 best solutions below

0
On

Answer: it's all about CORS, read here: https://amp.dev/documentation/guides-and-tutorials/learn/cors-in-email/

In the sandbox on https://amp.dev/ you won't be able to check your own JSON.

If you have an Apache server, then create(in the folder where the JSON file is located) .htaccess file and write the following code there:

Header add Access-Control-Allow-Origin: "*"
Header add AMP-Access-Control-Allow-Source-Origin: "[email protected]"
Header add Access-Control-Expose-Headers: "AMP-Access-Control-Allow-Source-Origin"

After that, AMP-list should work if you test locally or on your server.