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

fix(serveStatic): support serving file from absolute path for Deno and Bun #3108

Closed
wants to merge 1 commit into from

Conversation

oon00b
Copy link
Contributor

@oon00b oon00b commented Jul 7, 2024

fix: #3107

This PR may be related to issue #2200 .

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

Copy link

codecov bot commented Jul 7, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.87%. Comparing base (97ec652) to head (7196c96).
Report is 147 commits behind head on main.

Files with missing lines Patch % Lines
src/adapter/deno/serve-static.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3108   +/-   ##
=======================================
  Coverage   95.86%   95.87%           
=======================================
  Files         137      137           
  Lines       13510    13511    +1     
  Branches     2383     2285   -98     
=======================================
+ Hits        12952    12953    +1     
  Misses        558      558           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@oon00b
Copy link
Contributor Author

oon00b commented Jul 7, 2024

Sorry, the similar PR already existed in honojs/node-sever. I was missing it because I have never used Node.js.

Can I close my PR?

@yusukebe
Copy link
Member

yusukebe commented Jul 8, 2024

Hi @oon00b

We're not sure we will accept this PR, but regarding supporting the absolute path, this will be a new feature. There are some concerns, so please give us a time.

@schettn
Copy link

schettn commented Jul 12, 2024

If anyone has this error, this is my workaround:

 const relativePathToScript = path.relative(process.cwd(), __dirname)

  app.get(
    '/__studio/*',
    serveStatic({
      root: `${relativePathToScript}/../studio/dist`,

      rewriteRequestPath: path => {
        return path.replace('/__studio', '')
      },
      onNotFound: (path, c) => {
        console.log('not found', path, c.req.url)
      }
    })

@cj-1010-1414
Copy link

I think I have fixed the bug. It can now detect absolute and relative path without creating additional options or properties like isAbsolutePath, without creating additional test. How do I pull request?

@oon00b
Copy link
Contributor Author

oon00b commented Sep 24, 2024

completed in #3420

@oon00b oon00b deleted the servestatic-absolute-path branch September 24, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

serveStatic does not work when set absolute path to root
4 participants