Set baseUrl for Payload UI

default discord avatar
nettirk
2 weeks ago
5

I want to deploy payload under

/foo

instead on the root.


How can I set the baseUrl to

/foo

?


Currently payload redirects to

/admin

instead of

/foo/admin

and also tries to load static files from

/admin/assets/...

instead of

/foo/admin/assets/...
  • discord user avatar
    denolfe
    Payload Team
    2 weeks ago

    You can adjust the routes in the config. Here are the defaults

    https://github.com/payloadcms/payload/blob/main/packages/payload/src/config/defaults.ts#L48
  • default discord avatar
    nettirk
    last week

    @denolfe Thank you for your answer.


    After adjusting the routes config, the path in the built index.html (I assume thats the admin UI?) is changed to my desired prefix.


    But before I reach the admin UI, payload still tries to redirect to

    /admin

    instead of

    prefix/admin

    .


    I couldn't find any setting to change this behaviour



    This is the call stack in the inspector:


    It first redirects to add the missing trailing slash and than it redirects to /admin instead of /cos-cms/admin



    (Yes I'm currently hosting payload on our internal gitlab, it's only temporary 😉 But that's why I need to change the base path to

    cos-cms

    in my case)



    Thats my payload.config.ts


    I've set the variables to

    cos-cms
    image.png
    image.png
  • default discord avatar
    augdust
    last week

    Think there's a redirect to /admin happening in the server.ts file by default, worth checking out :)

  • discord user avatar
    denolfe
    Payload Team
    last week

    Yes, depending on the template you've used, there may be a redirect to /admin. This was added to assist newcomers in accessing the admin panel. Removing this may resolve your issue.

    https://github.com/payloadcms/payload/blob/main/templates/website/src/server.default.ts#L20-L23
  • default discord avatar
    nettirk
    last week

    @augdust @denolfe Thank you both!


    I removed the redirection in server.default.ts and know it works (aside from the redirection ;))

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.