无法在节点js上获取/

时间:2019-08-21 00:31:13

标签: node.js express

我在启动服务器时遇到困难。我没有在node.js中获得任何日志

当我进入localhost:5000时,出现错误消息:无法GET /

const passport = require('passport');
const GoogleStrategy = require('passport-google-oauth20').Strategy
const keys = require('./config/keys.js');
const app = express();```

```// route handler 
app.get(
    '/auth/google', 
    passport.authenticate('google', {
    scope: ['profile', 'email']
    })
);

//Deployment 
const PORT = process.env.PORT || 5000;
app.listen(PORT); ```


I expected the program to run in the browser. Instead I get "cannot GET/" error message

2 个答案:

答案 0 :(得分:0)

如果您想添加欢迎页面来测试您的应用,则必须收听'/'

app.get('/', (req, res) => {
      res.send('Welcome to Main Page');
    });

答案 1 :(得分:0)

if(Locale.getDefault().country.equals("US")) {
        val locale = Locale("en", "US")
        Locale.setDefault(locale)
    }

如果您需要在// will only be served only if you called localhost:5000/auth/google app.get( '/auth/google', passport.authenticate('google', { scope: ['profile', 'email'] }) ); 上获得回复,则需要为您的应用添加路由处理程序

localhost:5000/

您可以查看Express Routing了解更多详细信息

相关问题