谢谢管理员的回复,已经确认url中确实有中文:
http://cms.91jiaohao.com/#/verifyCoupon?weixinId=o6TNyw19lbcrc1koT5s6yKZeyuRw&dealerId=55f9133560b2b52cca5bc0e6&dealerName=开发测试专用
然后我使用了encodeURIComponent 进行转义,得到:
http%3A%2F%2Fcms.91jiaohao.com%2F%23%2FverifyCoupon%3FweixinId%3Do6TNyw19lbcrc1koT5s6yKZeyuRw%26dealerId%3D55f9133560b2b52cca5bc0e6%26dealerName%3D%E5%BC%80%E5%8F%91%E6%B5%8B%E8%AF%95%E4%B8%93%E7%94%A8
不过这个时间,页面变成直接提示Not Found了。
我查看日志,发现两点特别的:
[0mGET /authorize/dealer?code=031e4f2e5e91014a9f98d2939229a770&state=55e12ea860b2719ea5b36680&appid=wx26c1c7a55317221e [36m302 [0m993.646 ms - 458[0m
INFO 2016-04-08 13:15:57 [0mGET /authorize/http%3A%2F%2Fcms.91jiaohao.com%2F%23%2FverifyCoupon%3FweixinId%3Do6TNyw19lbcrc1koT5s6yKZeyuRw%26dealerId%3D55f9133560b2b52cca5bc0e6%26dealerName%3D%E5%BC%80%E5%8F%91%E6%B5%8B%E8%AF%95%E4%B8%93%E7%94%A8 [33m404 [0m15.594 ms - 41[0m
/authorize/dealer?code=031e4f2e5e91014a9f98d2939229a770&state=55e12ea860b2719ea5b36680&appid=wx26c1c7a55317221e 就是转向前的请求路径
/authorize/http%3A%2F%2Fcms.91jiaohao.com%2F%23%2FverifyCoupon%3FweixinId%3Do6TNyw19lbcrc1koT5s6yKZeyuRw%26dealerId%3D55f9133560b2b52cca5bc0e6%26dealerName%3D%E5%BC%80%E5%8F%91%E6%B5%8B%E8%AF%95%E4%B8%93%E7%94%A8的出现,让我感觉是转向没有成功,又重新请求了/authorize,只是/dealer变成了转义后的路径,有一种循环请求的感觉,但我明明是重定向到另一个主机上了啊,怎么会出现这种情况了,请管理员指点一二。
我之所以有这个判断,是因为另一个出错点,也出现了类似的情况,表现如下:
原始请求是这个:
[0mGET /apply/55e1283fddb23dad4373cbaa/55e12ea860b2719ea5b36680/55fb7e0a60b2ead5625f5d6b/%E4%BD%95%E5%B9%B3/56f0e7028ac2470054beb51f [36m302 [0m5.303 ms - 528[0m
代码是这个:
var url = global.cms_domain + '/#/apply?tenantId=' + tid + "&activityId=" + aid+ "&customerId=" + cid+ "&customerName=" + cname + "&couponId=" + couponId;
console.log(">>>url1:" + url);
url = encodeURIComponent(url);
console.log(">>>url2:" + url);
res.redirect(url);
转义前是这样的:http://cms.91jiaohao.com/#/apply?tenantId=55e1283fddb23dad4373cbaa&activityId=55e12ea860b2719ea5b36680&customerId=55fb7e0a60b2ead5625f5d6b&customerName=何平&couponId=56f0e7028ac2470054beb51f
转义后是这样的:
http%3A%2F%2Fcms.91jiaohao.com%2F%23%2Fapply%3FtenantId%3D55e1283fddb23dad4373cbaa%26activityId%3D55e12ea860b2719ea5b36680%26customerId%3D55fb7e0a60b2ead5625f5d6b%26customerName%3D%E4%BD%95%E5%B9%B3%26couponId%3D56f0e7028ac2470054beb51f
但在执行前面的代码以后:
系统还是在继续请这/apply/xxxxxx
保是说转义前变成了:
http://cms.91jiaohao.com/#/apply?tenantId=55e1283fddb23dad4373cbaa&activityId=55e12ea860b2719ea5b36680&customerId=55fb7e0a60b2ead5625f5d6b&customerName=何平&couponId=http://cms.91jiaohao.com/#/apply?tenantId=55e1283fddb23dad4373cbaa&activityId=55e12ea860b2719ea5b36680&customerId=55fb7e0a60b2ead5625f5d6b&customerName=何平&couponId=56f0e7028ac2470054beb51f
也就是转义的结果,变成了最后一个参数的值,然后重复请求当前请求,而且还不断的循环请求,不断叠加,导到重定向一直无法跳转到另一个主机的地址上去执行。
另外,其它没有中文参数的redirect,一切正常。