How do I prevent the “appspot.com” of my App Engine app?

蓝咒 提交于 2020-04-07 10:28:26

问题


I have a custom domain added that I added to App Engine. For example, let's say my custom domain is "example.com". My app is served with Node.js, and I when I deploy my app through App Engine, it gives me this address to access to it:

"example.appspot.com".

How do I prevent this? I want to serve my app only on "example.com".

SOLVED: I'm using this middleware to prevent those hostnames and it works, at least for what I kind of wanted:

var redirect = function(req, res, next) {
    if (req.hostname.search('appspot') !== -1) {
        res.redirect(301, 'https://www.example.com');
        next();
    }
    next();
};

app.use(redirect);

来源:https://stackoverflow.com/questions/60859930/how-do-i-prevent-the-appspot-com-of-my-app-engine-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!