Prerequisites
Fastify version
5.1.0
Plugin version
10.0.01
Node.js version
22.0.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
Ventura 13.6.6
Description
I'm not 100% sure if this is an issue with fastity/session or fastify/http-proxy.
I can get values from the session on normal routes. For example.
export default async function getImage(request, reply) {
const id = request.params["*"];
try {
const access_token = request?.session?.get('access_token') || null;
However, when I try in the preHandler in http-proxy plugin, it doesn't return anything, it's undefined.
fastify.register(fastifyHttpProxy, {
upstream:
process.env.NODE_ENV === "production"
? "http://xxxxxx:8080"
: "https:/xxxxxx/v1/graphql", // Replace with your Docker container's address
prefix: "/hasura", // The prefix for the proxy route
rewritePrefix: "/",
preHandler: (request, reply, done) => {
const access_token = request?.session?.get('access_token') || null;
console.log("Got access token from session", access_token);
done();
},
I'm setting the trustProxy to true, but still nothing. Like I say - all other routes work.
Any ideas?
Link to code that reproduces the bug
No response
Expected Behavior
The session should be available in the preHandler on @fastify-httpproxy
Prerequisites
Fastify version
5.1.0
Plugin version
10.0.01
Node.js version
22.0.0
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
Ventura 13.6.6
Description
I'm not 100% sure if this is an issue with fastity/session or fastify/http-proxy.
I can get values from the session on normal routes. For example.
However, when I try in the preHandler in http-proxy plugin, it doesn't return anything, it's undefined.
I'm setting the trustProxy to true, but still nothing. Like I say - all other routes work.
Any ideas?
Link to code that reproduces the bug
No response
Expected Behavior
The session should be available in the preHandler on @fastify-httpproxy