如何从后端脚本返回数据并避免出现此 Ngrok 错误页面?

use*_*669 1 ajax shopify ngrok

我正在尝试访问一个 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);
                     }
                  });
Run Code Online (Sandbox Code Playgroud)

在控制台中,我看到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>
Run Code Online (Sandbox Code Playgroud)

小智 5

添加跳过浏览器警告标头

$.ajax({
   type: 'GET',
   async: true,
   datatype: JSON,
   headers: { 
      'ngrok-skip-browser-warning': 'true' 
   }
   url: '/tools/app-script',
Run Code Online (Sandbox Code Playgroud)