Comments (6)
Try setting Fastify's ignoreTrailingSlash
option to true
.
const fastify = require('fastify')({
ignoreTrailingSlash: true
})
from fastify-static.
Released in 2.7.0
Thank you for your contribution!
from fastify-static.
Try setting Fastify's
ignoreTrailingSlash
option totrue
.const fastify = require('fastify')({ ignoreTrailingSlash: true })
This won't work in my use case since, I am not using fastify directly, rather building an object and passing it to a module that creates fastify. Can the same flag be implemented in fastify-static?
const fastifyStatic = require('fastify-static');
async function registerRoutes(app) {
app.register(fastifyStatic, {
prefix: '/docs',
root: path.join(__dirname, '../docs')
});
app.get('/foo', async (req, res)
}
// external module takes function to build routes
buildRoutes(registerRoutes);
from fastify-static.
Unfortunately that option is specific to fastify router, so you cannot set it on the module itself.
Lines 125 to 130 in e1ad93b
prefix: false
?
Would you like to send a PR for a different option that implement what you need?
from fastify-static.
So, I tried the option ignoreTrailingSlash: true and it still appends trailing slash :sad
However, if I modify
Line 110 in e1ad93b
to
const prefix = opts.prefix[opts.prefix.length - 1] === '/' ? opts.prefix : opts.prefix;
My static content is served at /docs without trailing slash, just like I need. I can make a PR to make it optional with the flag.
from fastify-static.
That'd be rad, thanks!
from fastify-static.
Related Issues (20)
- Forking send to @fastify/send to avoid CVE warning
- setNotFoundHandler and @fastify/static context issue HOT 2
- Parameter in route and serving files HOT 2
- Support URL for root parameter (and `file:` protocol) HOT 9
- Serve the same html for all get routes HOT 1
- Regression on isUtf8MimeType HOT 5
- Investigate path-scurry by @isaacs HOT 2
- Why @[email protected] bind [email protected] rather than 4.x HOT 1
- 我正在使用 nestjs,并通过 fastify-static 使用 public static,但我无法在打包时自动让目录 public 在目录 dist 内生成。 HOT 1
- . HOT 1
- inflight - transient dependency introduced memory leak HOT 8
- Correct module exports? HOT 2
- abstract the plugin to provide support of virtual file system HOT 1
- `FST_ERR_REP_ALREADY_SENT` when wrapping route handler HOT 5
- 404 when using wildcard HOT 3
- setting content-length HOT 5
- Is there a way to reduce the size of importing @fastify/static? HOT 1
- HTTP HEAD can not get the content-length(always 0) HOT 3
- Watch on file changes and reload HOT 2
- 400 Bad Request for files containing a `%` character
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastify-static.