drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.45k stars 1.1k forks source link

I can't serve my Nuxt.js static build files in Drogon #1379

Closed vahidke closed 4 months ago

vahidke commented 2 years ago

Describe the bug I built my Nuxt.js web application statically. And I serve it on Drogon. Everything works fine until I refresh my dynamic pages. and I get a "404 not found" message. I used the "addALocation" and set it in my static folder. but it dosen't solve it. In nginx, I can handle this problem with this piece of code:

 location / {
        try_files $uri $uri/ /index.html;
    }

To Reproduce Steps to reproduce the behavior:

  1. build nuxt js web application using "npm run generate" command
  2. move "dist" folder in the drogon build folder
  3. use "setDocumentRoot" and set your webapp build folder. for example: app().setDocumentRoot("./dist")
  4. run drogon
  5. go to your webapp address and enter a dynamic route. for example http://localhost:8848/post/100
  6. reload your webapp page
  7. see 404 not found page

Expected behavior refresh page normally like other static pages

Desktop:

hwc0919 commented 2 years ago

Looks like something regarding history route mode.

Try capture all path to your app entry point?