Koa.js - serving static files and REST API

前端 未结 3 2032
名媛妹妹
名媛妹妹 2021-02-09 02:50

I\'m new to koa.js library and I need some help. I\'m trying to make simple REST application using koa. I have a static html and javascript files I want to serve on route

3条回答
  •  死守一世寂寞
    2021-02-09 03:12

    const root = require('path').join(__dirname, 'client', 'build');
    app.use(serve(root));
    
    app.use(async ctx => {
        await send(ctx, `/index.html`, {
            root
        });
    });
    

提交回复
热议问题