Serve static can't handle globalprefix
Bidghur opened this issue · 1 comments
Bidghur commented
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
Using the '@nestjs/serve-static' package and serving my static html file with it. After I set up the global prefix to my application, I can not reach my served root as I expected.
I couldn't find any documention/post about this issue.
As we can see from the images:
Tested with Fastify and Express as well, doesn't seem to work with either of them.
Minimum reproduction code
https://github.com/Bidghur/static-serve-issue
Steps to reproduce
- npm i
- npm run start
- try to hit http://localhost:3000/globalprefix/static/example endpoint, should get a 404
Expected behavior
When I hit http://localhost:3000/globalprefix/static/example I should receive my static assets.
So the globalprefix should be added to my serve root path url.
Package
- I don't know. Or some 3rd-party package
-
@nestjs/common
-
@nestjs/core
-
@nestjs/microservices
-
@nestjs/platform-express
-
@nestjs/platform-fastify
-
@nestjs/platform-socket.io
-
@nestjs/platform-ws
-
@nestjs/testing
-
@nestjs/websockets
- Other (see below)
Other package
@nestjs/serve-static
NestJS version
9.4.3
Packages versions
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"@nestjs/serve-static": "^4.0.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0"
},
"devDependencies": {
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@types/express": "^4.17.13",
"@types/jest": "29.5.0",
"@types/node": "18.15.11",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "29.5.0",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "29.0.5",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "4.2.0",
"typescript": "^4.7.4"
}
Node.js version
18.9.0
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
No response
codingholt commented
When will this be fixed?