Skip to content

Route to proxy requets #2349

Answered by evantahler
dturton asked this question in Q&A
Dec 5, 2022 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

Yep! You'll want to make an action that only works for HTTP/web servers. I like the http-proxy package to handle the details:

import { Action, ParamsFrom, Connection } from "actionhero";
import { IncomingMessage, ServerResponse } from "http";
import * as httpProxy from "http-proxy"; // npm install --save --exact http-proxy @types/http-proxy

const PROXY_URL = "https://www.google.com";
const proxy = httpProxy.createProxyServer({});

export class ProxyAction extends Action {
  constructor() {
    super();
    this.name = "proxy";
    this.description = "I Proxy web requests";
    this.inputs = {};
    this.blockedConnectionTypes = ["websocket"]; // be sure to block all connection types (ser…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@dturton
Comment options

Answer selected by dturton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants