admin管理员组文章数量:1391955
As I implement passport's Google OAuth2.0 strategy, I realized I need the callback to hit the server, then from there, I can redirect to a different page depending on if the user needs to finish setting up their account or if their account is already setup.
The problem is that when a redirect to say /api/auth/google/callback, the react app seems to capture it and just loads a blank screen. Even when my backend server is off which hosts the frontend, I still managed to get a blank page (I'm guessing just because everything is cached).
I believe I have everything in the correct order: handle API requests first, then send off the static react app files.
// Initialize Passport
app.use(passport.initialize());
app.use(passport.session());
passport.use(localStrategy);
passport.use(googleStrategy);
app.use('/api', apiRouter);
// serve react app
app.use(express.static(path.join(__dirname, '../../frontend/dist')));
app.get('*', (req: Request, res: Response) => {
res.sendFile(path.join(__dirname, '../../frontend/dist/index.html'));
});
I tried configuring a proxy in the vite config file, but that only seems to work in development. Any thoughts? Is this even possible?
本文标签: reactjsVite React Proxy Requests to Backend in ProductionStack Overflow
版权声明:本文标题:reactjs - Vite React Proxy Requests to Backend in Production - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744705183a2620800.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论