Egg: 请问如何访问根目录下面的静态文件

Created on 16 Dec 2017  ·  8Comments  ·  Source: eggjs/egg

请问如何访问根目录下面的静态文件
谢谢!

Most helpful comment

app.router.get('/xxxx', async (ctx) => ctx.body = '文件内容')

发自我的 iPhone

在 2017年12月16日,14:19,xinnian1992 notifications@github.com 写道:

请问如何在路由中指向根目录呢?现在好像都需要控制器方法,你能给个demo吗?@@atian25


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

All 8 comments

为啥要放根目录

发自我的 iPhone

在 2017年12月16日,13:54,xinnian1992 notifications@github.com 写道:

请问如何访问根目录下面的静态文件
谢谢!


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

微信开发,需要放一个文件在根目录,然后验证 @atian25

现在文件无法被微信访问,所以无法验证

URL 路径跟文件没啥关系,你做个 router 即可

发自我的 iPhone

在 2017年12月16日,14:06,xinnian1992 notifications@github.com 写道:

现在文件无法被微信访问,所以无法验证


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

请问如何在路由中指向根目录呢?现在好像都需要控制器方法,你能给个demo吗?@@atian25

谢谢 @atian25

app.router.get('/xxxx', async (ctx) => ctx.body = '文件内容')

发自我的 iPhone

在 2017年12月16日,14:19,xinnian1992 notifications@github.com 写道:

请问如何在路由中指向根目录呢?现在好像都需要控制器方法,你能给个demo吗?@@atian25


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

给个建议,直接在 nginx 配置就行了。如果是 txt 文件内容,直接在 nginx 返回字符就行了,环保高效。

Was this page helpful?
0 / 5 - 0 ratings