Skip to content
Discussion options

You must be logged in to vote

I’m not sure if this approach is better, but http-proxy-middleware works fine. To use it with Hono, you need to bind HTTPBindings to Hono.

Here’s an example of the setup:

import { createProxyMiddleware } from "http-proxy-middleware";
import { type HttpBindings} from "@hono/node-server";

const proxy = createProxyMiddleware({
... your proxy setup
})
const app = new Hono<{ Bindings: HttpBindings }>();

app.use("*", (c, next) => {
	return new Promise((resolve, reject) => {
		proxy(c.env.incoming, c.env.outgoing, (err) => {
			if (err) {
				reject(err);
			} else {
				resolve();
			}
		});
	});
});

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

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

Answer selected by unbiased-dev
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants