如何在amp游乐场放置json文件

问题描述 投票:0回答:1

我正在尝试使用amp游乐场在我目前正在开发的google amp页面中复制我的问题。如何将自己的json文件放置在amp操场中,以便在操场上复制场景。https://playground.amp.dev

amp-html
1个回答
0
投票

要在AMP Playground中通过amp-list测试JSON,您需要启用CORS保护。请按照以下步骤操作:

  1. 确保从您可以控制的服务器中获取JSON
  2. 使用以下代码为AMP Playground启用CORS:
header("AMP-Access-Control-Allow-Source-Origin: https://playground.amp.dev"); 
header("Access-Control-Allow-Origin: https://playground.amp.dev");

[注意:这是PHP代码,如果您通过其他服务器端编程语言吐出JSON,请使用上述代码的版本,或者如果它本身是.json文件,请通过服务器启用CORS。

CORS in AMP

© www.soinside.com 2019 - 2024. All rights reserved.