Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serve static can't handle globalprefix #1280

Open
3 of 15 tasks
Bidghur opened this issue Sep 13, 2023 · 1 comment
Open
3 of 15 tasks

Serve static can't handle globalprefix #1280

Bidghur opened this issue Sep 13, 2023 · 1 comment

Comments

@Bidghur
Copy link

Bidghur commented Sep 13, 2023

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:
373394859_1752662201862145_7510347445378926788_n
375756412_173095079157796_5166660945827428272_n
372338699_1029157971842881_6046141653439077612_n
375006759_687657920060866_2952145945393382611_n
375237593_6671848689524906_9201333091414580869_n

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

  1. npm i
  2. npm run start
  3. 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

@kamilmysliwiec kamilmysliwiec transferred this issue from nestjs/nest Sep 14, 2023
@codingholt
Copy link

When will this be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants