VScode 中的 REST 客户端代理问题

tim*_*535 6 proxy node.js visual-studio-code

在 VSCode 中使用 REST 客户端扩展时,例如。

\n
Send Request\nGET http://localhost:4200/dashboard\n\n###\n
Run Code Online (Sandbox Code Playgroud)\n

我收到以下错误:

\n
Connection is being rejected. The service isn\xe2\x80\x99t running on the server,\nor incorrect proxy settings in vscode, or a firewall is blocking requests.\nDetails: RequestError: connect ECONNREFUSED 127.0.0.1:4200\n
Run Code Online (Sandbox Code Playgroud)\n

如何将我的 http 代理更改为 4200 而不是 127.0.0.1:4200 ?

\n

小智 5

对我有用的解决方案是用字符串更改服务器主机名(主机名:“127.0.0.1”)。

Deno/TS/Rest 客户端扩展 vscode

应用程序.ts

import { Drash } from "https://deno.land/x/drash@v1.4.3/mod.ts";
import { Api } from "./api.ts";

const server = new Drash.Http.Server({
  response_output: "application/json",
  resources: [Api],
});

server.run({
  hostname: "127.0.0.1", // Just here !
  port: 1854,
});

console.log("Server running...");
Run Code Online (Sandbox Code Playgroud)

api.ts

// @ts-ignore
import { Drash } from "https://deno.land/x/drash@v1.4.3/mod.ts";

export class Api extends Drash.Http.Resource {
  static paths = ["/"];
  public GET() {
    this.response.body = `Hello World! (on ${new Date()})`;
    return this.response;
  }
}
Run Code Online (Sandbox Code Playgroud)

请求http

GET http://localhost:1854/ HTTP/1.1
Run Code Online (Sandbox Code Playgroud)

或者

GET http://127.0.0.1:1854/ HTTP/1.1
Run Code Online (Sandbox Code Playgroud)