Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session not avabile in @fastify/http-proxy #278

Closed
2 tasks done
stefan1968 opened this issue Nov 20, 2024 · 1 comment
Closed
2 tasks done

Session not avabile in @fastify/http-proxy #278

stefan1968 opened this issue Nov 20, 2024 · 1 comment

Comments

@stefan1968
Copy link

stefan1968 commented Nov 20, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.1.0

Plugin version

11.0.1

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

@jsumners
Copy link
Member

Duplicate fastify/fastify-http-proxy#388

@jsumners jsumners closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants