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:
https://payloadcms.com/docs/rest-api/overview#custom-endpointsWhat I overlooked there was that setting
root
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
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.