Skip to content

Failed to serve static file from next side  #108

@raychunghk

Description

@raychunghk

Describe the bug
If I follow the guide on npm page to setup , in my main.ts

import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import { FastifyAdapter, NestFastifyApplication, } from '@nestjs/platform-fastify'; import { fastifyStatic } from 'fastify-static'; import { join } from 'path'; import { RenderService } from 'nest-next'; async function bootstrap() { const app = await NestFactory.create<NestFastifyApplication>(AppModule); app.setGlobalPrefix(/absproxy/5000`);

const service = app.get(RenderService);

service.setErrorHandler(async (err, req, res) => {
// send JSON response
res.send(err.response);
});

await app.listen(5000);
/* if (module.hot) {
module.hot.accept();
module.hot.dispose(() => app.close());
}*/
}
bootstrap();
const service = app.get(RenderService);

service.setErrorHandler(async (err, req, res) => {
// send JSON response
res.send(err.response);
});`
This two function calls will make the static file request become 404.
After removing them, it resumes normal.

Expected behavior
It shoudl serve my static file like /public/park.jpg to
http://mysite/park.jpg

To Reproduce

Repository URL:

Version
"dependencies": {
"@apollo/server": "^4.7.3",
"@emotion/react": "^11.11.0",
"@emotion/server": "^11.11.0",
"@mantine/carousel": "^6.0.13",
"@mantine/core": "^6.0.13",
"@mantine/dates": "^6.0.13",
"@mantine/dropzone": "^6.0.13",
"@mantine/ds": "^6.0.13",
"@mantine/form": "^6.0.13",
"@mantine/hooks": "^6.0.13",
"@mantine/modals": "^6.0.13",
"@mantine/next": "^6.0.13",
"@mantine/notifications": "^6.0.13",
"@mantine/nprogress": "^6.0.13",
"@mantine/prism": "^6.0.13",
"@mantine/spotlight": "^6.0.13",
"@mantine/tiptap": "^6.0.13",
"@nestjs/apollo": "^11.0.6",
"@nestjs/common": "^9.4.3",
"@nestjs/core": "^9.4.3",
"@nestjs/graphql": "^11.0.6",
"@nestjs/passport": "^9.0.3",
"@nestjs/platform-express": "^9.4.3",
"@nestjs/platform-fastify": "^9.4.3",
"@nestjs/serve-static": "^3.0.1",
"@next/bundle-analyzer": "^13.4.4",
"@nextui-org/react": "^1.0.0-beta.12",
"@prisma/client": "4.14.1",
"@tabler/icons": "^1.107.0",
"@tabler/icons-react": "^2.18.0",
"@tiptap/extension-link": "^2.0.3",
"@tiptap/react": "^2.0.3",
"@tiptap/starter-kit": "^2.0.3",
"@types/graphql-fields": "^1.3.5",
"apollo-server-express": "^3.12.0",
"axios": "^1.4.0",
"body-parser": "^1.20.2",
"clsx": "^1.2.1",
"cookie-parser": "^1.4.6",
"cookies-next": "^2.1.1",
"date-fns": "^2.30.0",
"dayjs": "^1.11.7",
"docxtemplater": "^3.37.10",
"dotenv": "^16.0.3",
"embla-carousel-react": "^7.1.0",
"eslint": "^8.40.0",
"exceljs": "^4.3.0",
"express": "^4.18.2",
"fastify-static": "^4.7.0",
"fetch": "^1.1.0",
"fs": "^0.0.1-security",
"graphql": "^16.6.0",
"graphql-fields": "^2.0.3",
"gray-matter": "^4.0.3",
"ical2json": "^3.1.2",
"ics-to-json": "^1.0.0",
"ics-to-json-extended": "^1.1.4",
"jszip": "^3.10.1",
"kill-port": "^2.0.1",
"libreoffice-convert": "^1.4.1",
"md5": "^2.3.0",
"mo": "^1.7.3",
"multer": "^1.4.5-lts.1",
"nest-next": "latest",
"next": "^13.4.0",
"node-unoconv": "^1.0.5",
"nodemon": "^2.0.22",
"passport-jwt": "^4.0.1",
"pizzip": "^3.1.4",
"prisma": "^4.14.0",
"prisma-typegraphql-types-generator": "^1.5.14",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.44.2",
"reflect-metadata": "^0.1.13",
"remark": "^14.0.2",
"remark-html": "^15.0.2",
"rxjs": "^7.2.0",
"simple-odf": "^3.0.3",
"sqlite3": "^5.1.6",
"swr": "^2.1.5",
"type-graphql": "^2.0.0-beta.2",
"typegraphql-nestjs": "^0.5.0",
"winston": "^3.8.2",
"xlsx": "^0.18.5"
},

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions