Skip to content

微信分享域名配置问题 #194

@wufangjian

Description

@wufangjian

image

请教一下, 在做微信分享的过程遇到的路由问题。 怎样才能通过 http://www.xxxx.com/MP_verify_aaaaaaaaaa.txt 该链接访问到 MP_verify_aaaaaaaaaa.txt资源?


通过配置中间件插件(静态化)可以吗?这样做是否合理

module.exports.static = function(app, conf){
    return function(){
        app.use(conf.urlPattern, yog.express.static(conf.staticPath, conf.options));
        app.use('/MP_verify_aaaaaaaaaa.txt', yog.express.static(yog.ROOT_PATH + '/MP_verify_aaaaaaaaaa.txt', conf.options));
        //拦截404
        app.use(conf.urlPattern, conf.notFound);        
    };
};

module.exports.static.defaultConf = {
    options: {
        maxAge: 0
    },
    staticPath: yog.ROOT_PATH + '/static',
    urlPattern: '/static',
    notFound: function(req, res){
        res.status(404);
        res.send('404: Resource not Found');
    }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions