Http - 将正文写入连接时出错:握手未完成

问题描述 投票:0回答:1

我收到 400 错误请求错误“您的浏览器发送了无效请求。”当我想访问我的网站时。这是我在控制台中得到的错误:

enter image description here

我的服务器代码:

import { Application} from "https://deno.land/x/[email protected]/mod.ts";
import { send } from "https://deno.land/x/[email protected]/send.ts";
import { viewEngine, ejsEngine, oakAdapter } from "https://deno.land/x/[email protected]/mod.ts";


import router from './routes.ts';



const port = Deno.env.get("PORT") || 4000

const app = new Application()

app.use(viewEngine(oakAdapter, ejsEngine));

app.use(router.routes());
app.use(router.allowedMethods());

app.use(async(ctx,next) => {
  await send(ctx,ctx.request.url.pathname,{
      root: `${Deno.cwd()}`
  });
  next();
});







try{
  console.log(`Server running on port ${port}`);
  await app.listen({port, certFile: "./sites/vainastar.com/vainastar.com-2023-03-27.crt", keyFile:"./sites/vainastar.com/vainastar.com-2023-03-27.key", alpnProtocols: ["h2", "http/1.1"],secure:true});
  
}catch(e) {
  console.log("there is an error");
  console.log(e);
}

我添加了 alpnprotocols 选项但没有变化,我也会尝试重新加载缓存......有人知道这个错误是什么吗?

我正在阅读来自 github 的旧讨论,我认为我的问题可能与他们使用 Deno 所经历的事情有关……以及 SSL 证书。我认为我必须为请求使用代理或切换到 node.js :(

https://github.com/denoland/deno/issues/6427

https://github.com/denoland/deno/issues/6427

ssl https deno http-status-code-400 oak
1个回答
0
投票

由于我的网站位于网络托管远程服务器(云服务器)中,我不需要证书文件来拥有 https,因为我在托管商提供的代理下,只需要端口,所以我必须行为就像一个 http 应用程序 ...

© www.soinside.com 2019 - 2024. All rights reserved.