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 available in @fastify/http-proxy #388

Open
2 tasks done
stefan1968 opened this issue Nov 20, 2024 · 0 comments
Open
2 tasks done

Session not available in @fastify/http-proxy #388

stefan1968 opened this issue Nov 20, 2024 · 0 comments

Comments

@stefan1968
Copy link

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

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

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

1 participant