修复路由

This commit is contained in:
zyc404 2023-10-08 18:56:08 +08:00
parent d6fb62c424
commit 6e5ef2e1f5

View file

@ -51,8 +51,9 @@ async function routes(fastify, options) {
return reply
})
fastify.setNotFoundHandler((request, reply) => {
if (request.method === 'GET') {
reply.sendFile('plugins/chatgpt-plugin/server/static/index.html')
if (request.method == 'GET') {
const stream = fs.createReadStream('plugins/chatgpt-plugin/server/static/index.html')
reply.type('text/html').send(stream)
} else {
reply.code(404).send(new Error('Not Found'))
}