egg icon indicating copy to clipboard operation
egg copied to clipboard

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

Open xinnian1992 opened this issue 8 years ago • 8 comments

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

xinnian1992 avatar Dec 16 '17 05:12 xinnian1992

为啥要放根目录

发自我的 iPhone

在 2017年12月16日,13:54,xinnian1992 [email protected] 写道:

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

— 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 avatar Dec 16 '17 06:12 atian25

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

xinnian1992 avatar Dec 16 '17 06:12 xinnian1992

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

xinnian1992 avatar Dec 16 '17 06:12 xinnian1992

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

发自我的 iPhone

在 2017年12月16日,14:06,xinnian1992 [email protected] 写道:

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

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

atian25 avatar Dec 16 '17 06:12 atian25

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

xinnian1992 avatar Dec 16 '17 06:12 xinnian1992

谢谢 @atian25

xinnian1992 avatar Dec 16 '17 06:12 xinnian1992

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

发自我的 iPhone

在 2017年12月16日,14:19,xinnian1992 [email protected] 写道:

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

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

atian25 avatar Dec 16 '17 06:12 atian25

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

airyland avatar Dec 16 '17 13:12 airyland