標籤:https doc mod rom 檔案 name listen module roo
Docs: https://docs.nestjs.com/techniques/mvc
main.js
import { NestFactory} from '@nestjs/core';import { AppModule} from './app.module';import { join } from 'path'async function bootstrap() { const app = await NestFactory.create(AppModule); app.useStaticAssets(join(__dirname, '..', 'public')) // http://localhost:5000/xxx.txt // app.useStaticAssets('public') 跟上面一樣 await app.listen(5000);}bootstrap();
設定虛擬路徑
yarn add fastify point-of-view handlebars fastify-static
import { NestFactory, FastifyAdapter} from '@nestjs/core';import { AppModule} from './app.module';import { join } from 'path'const l = console.log;async function bootstrap() { const app = await NestFactory.create(AppModule, new FastifyAdapter()); app.useStaticAssets({ root: join(__dirname, '..', 'public'), prefix: '/static/', }); // http://localhost:5000/static/xxx.txt await app.listen(5000)}bootstrap();
Nestjs 設定靜態檔案,public