Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 在nodejs中点击请求时本地服务器和EC2服务器上的响应差异_Node.js_Amazon Ec2_Server_Request_Local - Fatal编程技术网

Node.js 在nodejs中点击请求时本地服务器和EC2服务器上的响应差异

Node.js 在nodejs中点击请求时本地服务器和EC2服务器上的响应差异,node.js,amazon-ec2,server,request,local,Node.js,Amazon Ec2,Server,Request,Local,好的,所以我没有从我的上一个五月中得到任何信息,因为我没有那么清楚地说明我所面临的问题,所以希望这次我能为我的问题找到解决方案: var request = require("request"); var options = { method: 'GET', url: 'https://shop.advanceautoparts.com/web/AAPStoresWithAvailableInventoryCmd', qs: { quantity: '1', partN

好的,所以我没有从我的上一个五月中得到任何信息,因为我没有那么清楚地说明我所面临的问题,所以希望这次我能为我的问题找到解决方案:

var request = require("request");
var options = { method: 'GET',
  url: 'https://shop.advanceautoparts.com/web/AAPStoresWithAvailableInventoryCmd',
  qs: 
   { quantity: '1',
     partNumber: '2130015-P',
     storeId: '10151',
     catalogId: '10051',
     langId: '-1',
     loadStoresComponent: 'true',
     latitude: '',
     longitude: '',
     prefStoreNickName: '8511' },
  headers: 
   { accept: 'application/json, text/plain, /',
     'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36',
     'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8',
     origin: 'https://shop.advanceautoparts.com' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});
当我在本地ENV尝试这一点时,我得到了关于我需要什么的准确数据。 但是当相同的代码在我的EC2服务器上执行时,我从上面的代码中得到了一个笨拙的响应

本地响应

{
"loadStoresComponent": ["true"],
"langId": ["-1"],
"quantity": ["1"],
"prefStoreNickName": ["8511"],
"latitude": [""],
"longitude": [""],
"authToken": "-1002%2C3a0VN%2Bt240MbliDjfWLSDJxolLA%3D",
"catalogId": ["10051"],
"DM_PersistentCookieCreated": ["true"],
"partNumber": ["2130015-P"],
"storeId": ["10151"],
"Result": {
"view": "availableStoresList",
"storesListMap": [
{
"inStock": true,
"state": "NC",
"isPrefStore": false,
"distance": 0,
"storeBrand": "AAP",
"city": "MATTHEWS",
"latitude": "35.137527",
"address1": "9507 INDEPENDENCE BLVD.",
"zipCode": "281050000",
"nickName": "8511",
"phone": "704-845-5004",
"longitude": "-80.715079"
},
{
"inStock": true,
"state": "NC",
"isPrefStore": false,
"distance": 4,
.....
.....
}
服务器上的响应

<div class="pagewidth">
  <div class="logo">&nbsp;</div>
  <div id="tagline">&nbsp;</div>
  <div class="clear">&nbsp;</div>
  <div class="header">&nbsp;</div>
  <div class="content">
    <p class="heading">We're offline for a tune-up, we'll be up and  running smoothly very soon. </p>
    <p class="heading">In the meantime, here are some other options available:</p>
    <div class="section group">
      <div class="col span_1_of_4"> Visit an <br />
        <strong>Advance Auto Parts store</strong><br />
        <a href="http://stores.advanceautoparts.com/"><img src="/MaintPage/images/DM150205_maintenance_page_07.png" width="200" height="125" border="0" /></a> </div>
      <div class="col span_3_of_4"> Sign up for <br />
        <strong>SpeedPerks Rewards</strong><br />
        <a href="http://www.speedperks.com"><img src="/MaintPage/images/sp-logo.png" width="204" height="100" border="0" style="margin-top:20px;" /></a> </div>
      <div class="col span_4_of_4"> View us on Social Media <strong><br />
        Facebook/Twitter/Blog</strong><br />
        <a href="https://www.facebook.com/advanceautoparts"><img src="/MaintPage/images/DM150205_maintenance_page_12.png" width="110" height="125" border="0" /></a><a href="https://twitter.com/AdvanceAuto"><img src="/MaintPage/images/DM150205_maintenance_page_16.png" width="92" height="125" border="0" /></a><a href="http://blog.advanceautoparts.com/"><img src="/MaintPage/images/button-m.png" width="90" height="125" border="0" style="margin-left:0px;" /></a> </div>
    </div>
    <div class="clear">&nbsp;</div>
    <p class="heading">We appreciate your patience – on your next visit, <strong>use coupon code PS20 for 20% off your purchase. </strong></p>
    <p class="coupon"><img src="/MaintPage/images/DM150205_maintenance_page_21.png" width="354" height="134" /></p>
    <p style="margin:30px; text-align:center;">We look forward to serving you,<br />
      The Advance Team</p>
    <p style="margin:30px; text-align:center;">&nbsp;</p>
  </div>
</div>

我们正在离线进行调整,我们很快就会恢复正常运行

同时,以下是一些其他可用选项:

访问一个
高级汽车配件店
注册
特快专享奖励
在社交媒体上查看我们
Facebook/Twitter/Blog

我们感谢您的耐心–在您下次访问时,使用优惠券代码PS20,可享受20%的折扣

我们期待着为您服务,
先遣队

基本上,这是一个离线页面(没有粘贴整个HTML正文和CSS),我觉得他们拒绝返回我请求的响应

我也尝试过在我的通话中添加
x-forwarded-for
,但没有成功。 通过在rails中添加
x-forwarded-for
,我得到了一个准确的响应,但我想可能需要在请求中添加一些额外的头或其他任何东西来获得所需的结果


对我的问题有什么想法吗?

请确保您在EC2服务器中输入了正确的url(),没有任何输入错误。我不强制代码中的任何其他问题。这是实际的URL。我使用postman for nodejs代码片段作为请求代码。我很想知道,您是如何在EC2实例中运行此代码的。您是在使用上面的共享邮递员代码片段执行还是以其他方式执行它。我可以通过在URL中创建打字错误来获得上面提到的错误页面。只是给你一个调试这个问题的提示。输入错误的URL:(aapstoreswitthavailableinventorycmd作为aapstoreswitthailableientorycmd)如果输入错误,它将返回
我们无法处理您的请求。请再试一次
,但在我的场景中,它会显示我们正在脱机进行调整,我们很快就会启动并顺利运行。对不起,我是nodejs的新手,通过在我的EC2实例中运行此代码,我的意思是,我在我的登台服务器上执行了节点,并粘贴了代码,希望这次我能说清楚。