今日已更新 280 条资讯 | 累计 22470 条内容
关于我们

How do you handle a real backend with nextjs?

/u/Consistent_Tutor_597 2026年05月28日 20:51 3 次阅读 来源:Reddit r/webdev

Hey guys. We used to write our backend code primarily in python flask. And then we added nextjs/react for frontend. But the way it was done by previous devs was nextjs talks to flask internally on localhost and passes requests onto flask after handlingu the auth. As there's only one public subdomain. But often times it feels so ceremonial. Because flask has a route. Then nextjs has an equivalent route. And for basic stuff it almost looks equal size in the 2 places. There's endpoints just to pass a request on. And then someone suggested to do rewrites for certain stuff but that just splits the ability to where do you find code related to a certain thing like whitelabel. You go and first find it in nextjs routes, then u see if it's in any of the rewrites. And then you go and dig the flask equivalent. Since nextjs is totally really a real backend. And it anyways sits in the middle to interject every request due to auth etc. Makes me wonder if it's a bad idea to let it handle most of the crud stuff. Because rn it gets a request to say serve a logo. It gets a route handles headers etc and sends a request to flask hey can you grab that logo for me. And then ships it back. But it's gonna take just a few lines more for nextjs to end up doing the whole thing itself. Now the only issue is. That would sort of split the duties a bit. And the line might be slightly arbitrary. I personally prefer if we can keep all the business logic in python as that's what our team understands best. And also do certain data science stuff for which you anyways need python. But overall is it a bad idea to split duties between 'backends' like this. Especially the simpler crud stuff. Or how else would you suggest the backend handles the requests. Is route handlers the way or rewrites. Thanks. submitted by /u/Consistent_Tutor_597 [link] [留言]

本文内容来源于互联网,版权归原作者所有
查看原文