Using API routes internally
Unanswered
Masai Lion posted this in #help-forum
Masai LionOP
I need to do some server-side rendered pages, and as such we've got some API routes to hit internally.
Is it acceptable to use API routes internally within the same next application?
OR is it best to create a "Service" and import that to hit external API's - As I've noticed we're running into some build issues on CI/CD pipelines with GitHub as it won't build
Is it acceptable to use API routes internally within the same next application?
OR is it best to create a "Service" and import that to hit external API's - As I've noticed we're running into some build issues on CI/CD pipelines with GitHub as it won't build
5 Replies
Masai LionOP
Thank you, I'll have a read
Giant panda
Short answer: the latter. Don't fetch your own API routes in server-side code and extract the business logic into callable functions.
joulev's post has more details.
Masai LionOP
Really appreciate the help thank you! Just needed to confirm