Fetching from a custom endpoint?

default discord avatar
4 months ago

Hello, I'm attempting to setup a custom route with a UI for importing data from outside payload. So far, I've got the custom route for the page working, I've also added a custom express middleware that could potentially be used to handle the custom logic I need. However, when I try just fetching the URL, the page hangs... not sure if there's a specific way this needs to be handled according to payload.

Any thoughts welcome!

Got the hanging to stop, but all my custom requests to my middleware is getting 404'd

Scratch that, not sure why the hanging keeps happening (have to keep restarting the tab to test)

Think I found the solution here:


What I overlooked there was that setting


to true while avoiding an existing namespace made it work for me.

for example:

const config :Config = {
    // other configs..
    endpoints: [
            path: '/some-scope/some-path/and/so/on',
            method: 'get',
            root: true,
            handler: async (req, res, next) => {
                res.status(200).send({ message: 'example response' })

hope someone finds this helpful

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


    Connect with the Payload Community on Discord



    Can't find what you're looking for?

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