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

requestIP return null when using sign cookie #655

Open
armada45-pixel opened this issue May 23, 2024 · 0 comments
Open

requestIP return null when using sign cookie #655

armada45-pixel opened this issue May 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@armada45-pixel
Copy link

armada45-pixel commented May 23, 2024

What version of Elysia.JS is running?

1.0.21

What platform is your computer?

Alpine Linux v3.18 on Docker 4.30.0 ( Desktop ) on WSL version: 2.1.5.0 on Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

when have cookie need to sign, socketAddress from requestIP will return will

What is the expected behavior?

requestIP return normal socketAddress object

What do you see instead?

null

Additional information

import { Elysia } from "elysia"

const app = new Elysia({
  name: "mainApp",
  serve: {
    hostname: "0.0.0.0",
    port: 8082,
  },
  cookie: {
    sign: true, // If false requestIP return object of socketAddress
    secrets: process.env.COOKIE_KEY,
  },
})
  .use((app) =>
    app.derive(({ request }) => ({
      ip: app.server?.requestIP(request)?.address,
    })),
  )
  .derive({ as: "global" }, ({ cookie: { someMilk } }) => ({
    get milkType() {
      const value = "chocolate milk"
      someMilk.set({
        value: value,
      })
      return value
    },
  }))
  .get("/", ({ ip }) => {
    return ip + "some message"
  })
  .listen({}, ({ development, hostname, port }) => {
    console.log(
      `🦊 Elysia is running at ${hostname}:${port} ${
        development ? "🚧 in development mode!🚧" : ""
      }`,
    )
  })
@armada45-pixel armada45-pixel added the bug Something isn't working label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant