Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Host/Headers in 3.0.beta.32

default discord avatar
_headless2 years ago
14

Hello! So I am trying to move the multi-tenant example over to 3.0 and ive faced some issues regarding "host". in the multi tenant example they use req.headers.host which gives you the domain your accessing the website by.



if you added

abc.localhost.com

and

bbc.localhost.com

to your hosts file, the multi-tenant example will properly show the domain in the

req.headers.host

property.



However, in 3.0 req.headers does not exists (supposedly) and

host

is now on the top-level of req. (

req.host

)



my issue is, is that

req.host

will

ALWAYS

return

localhost

in development unless you manually set

-H

with nextjs, but this ends up not creating the system you want to test multiple subdomains locally.



I understand this issue probaly comes from nextjs itself and hoping a patch can be added to bring back the functionality in local development of

req.host

or if you add back

req.headers.host

that the value will be the actual value that represents how your accessing it, regardless if they all point to localhost or not.



😢

  • default discord avatar
    ingrid7412 years ago

    Not moved it yet but I'm working out of the multitenant example too, working locally with hosts as well.



    This may be slightly of topic, but today I found Vercel doesn't seem to add headers.host (and headers.origin) to requests at all(?), except on rewrites, where it sets headers.host to recipient host. Which is a wrench in the Payload multi-tenant example access control setup.

  • default discord avatar
    vishalnath32332 years ago

    Hi, have you managed to figure out a solution to the req.headers.host being redirected to localhost? My multi-tenant payload system pretty much has come to a stop now that every thing is getting redirected to localhost.



    I would apprecaite if you have any ideas or workarounds on this.

  • default discord avatar
    _headless2 years ago

    Personally no, I believe this just has to do with nextjs. It works in production on vercel just not in a local environment. So I basically have faith that subdomains work properly and just access everything from the localhost in dev

    @1074867232632488038
  • default discord avatar
    vishalnath32332 years ago

    Thanks

    @131645553070178305

    !

  • default discord avatar
    _headless2 years ago

    This seems to be broken again



    in the latest version



    req.host now is localhost EVEN on vercel

  • default discord avatar
    absolutegravitas2 years ago

    yep same issue here also being spammed with apiKey not found

  • default discord avatar
    _headless2 years ago

    This as well!



    @360823574644129795

    would you know?

  • discord user avatar
    denolfe
    2 years ago
    @131645553070178305

    Have you submitted an issue? Can you do so or link to existing? (I'm not able to find one)

  • default discord avatar
    _headless2 years ago
    @967118574445547650

    https://github.com/payloadcms/payload/issues/6392

    just created one



    Host/Headers in 3.0.beta.32



    is there any updates on this?



    @967118574445547650

    sorry for the ping, i know the issue has not been updated or spoken on but i was curious if you had any insight into it?



    😭



    friday im suppose to show the client how to use it and i wont be able to let him use his admin account for the tenant since req.host just doesnt work

  • discord user avatar
    denolfe
    2 years ago

    Pretty sure

    @281120856527077378

    starting looking into this one again today

  • default discord avatar
    _headless2 years ago

    Okay great thanks



    I just checked the issue and saw he was added

  • discord user avatar
    jarrod_not_jared
    2 years ago
    @131645553070178305

    can you give this a shot on the latest beta?



    should be fixed

  • default discord avatar
    _headless2 years ago

    I’ll do it right now!



    @281120856527077378

    you fixed it! Thank you haha, right in the nick of time too

  • discord user avatar
    jarrod_not_jared
    2 years ago

    haha I know right 😆

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.