我正在尝试访问一个 javascript 文件,该文件是我的 Shopify 应用程序的一部分,并记录从后端 php 脚本返回的数据,但我收到一个 Ngrok 错误页面。我已将代理 url 添加到 Shopify 上的应用程序代理设置中,并按如下方式访问它:
$.ajax({
type: 'GET',
async: true,
datatype: JSON,
url: '/tools/app-script',
data: {
// search: search,
shop: window.location.href,
url: window.location.href
},
beforeSend: function() {
// function while sending...
},
success: function(result) {
console.log('SUCCESS');
// const data = JSON.parse(result);
console.log(result);
},
error: function(error) {
// Create function for errors in the page request.
console.log('ERROR');
console.log(error);
}
});
在控制台中,我看到
result
正在被记录,因为请求成功,但是,我没有得到我期望的数据。相反,我收到下面的 Ngrok 消息:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="author" content="ngrok">
<meta name="description" content="ngrok is the fastest way to put anything on the internet with a single command.">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link id="style" rel="stylesheet" href="https://cdn.ngrok.com/static/css/error.css">
<noscript>You are about to visit a123-12-12-123-12.eu.ngrok.io, served by xxx.xxx.xxx.xxx. This website is served for free through ngrok.com. You should only visit this website if you trust whoever sent the link to you. (ERR_NGROK_6024)</noscript>
<script id="script" src="https://cdn.ngrok.com/static/js/error.js" type="text/javascript"></script>
</head>
<body id="ngrok">
<div id="root" data-payload=""></div>
</body>
</html>
添加跳过浏览器警告标题
$.ajax({
type: 'GET',
async: true,
datatype: JSON,
headers: {
'ngrok-skip-browser-warning': 'true'
}
url: '/tools/app-script',
标题:{ “内容类型”:“应用程序/json”, "ngrok-skip-browser-warning": "true", // 如果需要添加任何附加标头 }
添加此标题