Using a single Vercel monorepo deployment, the frontend returns 404 errors when deployed from the root while the API fails when deployed from the client. How can both be served correctly?
The solution involves adjusting the deployment configuration so that the API and frontend each function independently. In my experience with similar Vercel monorepo setups, creating explicit paths and rewrites using vercel.json prevents the framework from defaulting to a single deployment context. Specifically, ensuring the build outputs for the frontend and API are separated resolves the conflict. This setup also involves checking that the correct root directories for each service are defined in the project settings, which allows Vercel to recognize and serve both components appropriately.
After delving into similar issues, I found that establishing separate build configurations for both the frontend and API within the same repository is key. This approach mandates explicit assignment of directories and build commands in the configuration file, thereby preventing conflicting routing between the two deployments. In a previous project, ensuring that each service maintained its own deployment context eradicated the persistent 404 errors. This method allowed for more effective debugging and smoother operations on Vercel, making it a sound solution for such monorepo challenges.
i think a good fix is to set up two distinct projects rather than force one build to handle both. rough experiments showed that misconfigured rewrites in vercel.json often cause the 404 errors you see. try separeting the builds and paths for more clarity.
hey, im wonderin if tryin to tweak the rewrite paths more granularly might help fix those conflict issues. maybe the deploy root settings need an extra look. what other solutons have you played with so far?
hey, checkin your build cmds and rewrites might do the trick. i had a similar issue and splitting the API/frontend deployments while double checkng settings solved it. try revising the deploy roots!