当用户单击“使用Google登录”时,该用户将被带到Google OAuth流程进行登录过程。但是,单击浏览器后,只需将其URL更改为localhost:3000 / auth / google,就不会发生任何事情。如果我明确提供完整的href,则效果很好
http:// localhost:5000 / auth / google
应用程序组件:
import './App.css';
import React, { Component } from 'react';
class App extends Component {
render() {
return (
<div className="App">
<a href="/auth/google">Sign in using google</a>
</div>
);
}
}
export default App;
package.json
{
"name": "client",
"version": "0.1.0",
"private": true,
"proxy": {
"/auth/google": {
"target": "http://localhost:5000/"
}
},
删除package.json上的代理,然后尝试在src目录上创建create setupProxy.js,然后npm安装http-proxy-middleware
const { createProxyMiddleware } = require("http-proxy-middleware");
const proxy = require("http-proxy-middleware");
module.exports = function (app) {
app.use(
createProxyMiddleware(
"/auth/google",
// replace with your endpoint
{ target: "http://localhost:5000" } // replace with your target
)
);
};
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句