我有一个使用https的网络服务器,它使用h2o2代理/ api / *请求到我使用http的api服务器。两个服务器都构建在HapiJS框架上。
从/ login页面,用户可以向/ api / authenticate提交身份验证数据,从中返回JWT cookie和(我坚持的用户)将用户重定向到/(或任何页面)。 / p>
请求成功通过代理,只要我只使用h.response
而不是h.redirect
,生成的令牌就会将其返回给客户端。
当我将h.redirect
与/images/background.png
等相对网址一起使用时,我得到404: not found
。
当我将h.redirect
与https://example.com/等完整网址一起使用时,我得到Protocol "https:" not supported. Expected "http:"
。即使我输入了网址http://example.com/(重定向到https://example.com/),它仍会将请求重新构建为https请求。
使用相对网址会很可爱,但至少要让重定向与完整网址一起使用是必须的。
我尝试将api服务器切换到https(虽然我认为保持http是正常的吗?)但是证书只对example.com有效,而不是ip。我宁愿不用ip作为alt重新签署证书。我想坚持api服务器的http,但我不确定该怎么做才能使它工作。非常感谢任何想法或建议。
我正在使用hapi 17.5.1用于两个服务器和h2o2 8.2.1
TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
at new ClientRequest (_http_client.js:109:11)
at Object.request (https.js:272:10)
at internals.Client._request (webpack:///./node_modules/h2o2/node_modules/wreck/lib/index.js?:192:24)
at options.beforeRedirect (webpack:///./node_modules/h2o2/node_modules/wreck/lib/index.js?:241:38)
at Object.options.beforeRedirect.options.beforeRedirect (webpack:///./node_modules/h2o2/node_modules/wreck/lib/index.js?:100:134)
at ClientRequest.onResponse (webpack:///./node_modules/h2o2/node_modules/wreck/lib/index.js?:239:24)
at Object.onceWrapper (events.js:273:13)
at ClientRequest.emit (events.js:182:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:546:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)