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.

How to redirect directly localhost:3000/admin port when server start

default discord avatar
bishnupriyalast year
9

How to redirect directly localhost:3000/admin port when server start

  • default discord avatar
    zed0547last year

    Hi

    @1313307473528225872

    👋



    I'm confused what you mean here, can you provide some clarification on your use case and what issue you're experiencing specifically?

  • default discord avatar
    stefan5412last year

    if you want to redirect it to some other port just do PORT=8080 pnpm dev, for local, but similar thing for prod



    Keep in mind that if you tweak something, you could loose images, etc because of wrongly set PORT.

  • default discord avatar
    bishnupriyalast year

    No,I mean how to redirect home directory (/) to /admin in payload admin panel .once start the server .I just want only the admin panel.how to do that?

  • default discord avatar
    zed0547last year

    See here to change

    /admin

    to

    /

    :

    https://payloadcms.com/docs/admin/overview#customizing-root-level-routes

    Keep in mind you also have to move the (payload)/admin to the (payload) root folder



    As specified in that warning there

  • default discord avatar
    bishnupriyalast year

    in my home directory, where my frontend is accessible at /, and the Payload Admin panel is at /admin. However, I want to disable the frontend and automatically redirect to /admin when the server starts. How can I achieve this using middleware or configuration within Payload CMS?

  • default discord avatar
    zed0547last year

    You can setup redirects via next.config.js to automatically redirect from / to /admin

    https://nextjs.org/docs/app/api-reference/config/next-config-js/redirects

    But this is not a Payload concept, this is something more to do with Next

  • default discord avatar
    bishnupriyalast year

    Thanks for the help! I'm new to both Next.js and payload.js and still learning how things work.Before this, I used Filament,and I'm trying to compare how payload and filament handle things.So far I see that Payload is more flexible with Next.js



    In Filament, there's a built-in feature for seeding data.But i couldn't find a similar feature in payload.Should I write a custom script,or is there a recommended approach?

  • default discord avatar
    zed0547last year

    I would do that either in a custom endpoint like the website template does, or use the

    onInit

    function that runs once the server starts, with Payload there's many ways to seed data honestly



    Glad you figured the redirects out though

  • default discord avatar
    bishnupriyalast year

    How can I seed 20 dummy data in each collection automatically in payload.js using faker.js or any other method? can you provide an example?

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.