export fastify options
blasdfaa opened this issue · 3 comments
blasdfaa commented
How do I specify global settings for fastify
? I started the project using the fastify-cli
import path from 'path'
import AutoLoad from '@fastify/autoload'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
export const options = {
ignoreTrailingSlash: true // these settings are ignored
}
export default async function (fastify, opts) {
fastify.register(AutoLoad, {
dir: path.join(__dirname, 'plugins'),
options: Object.assign({}, opts)
})
fastify.register(AutoLoad, {
dir: path.join(__dirname, 'routes'),
options: Object.assign({}, opts)
})
}
Environment
- node version: 20
- fastify version: 4.26.1
- os: Mac
mcollina commented
Take a look at the README: https://github.com/fastify/fastify-cli?tab=readme-ov-file#options.
If you need to change the settings that are not mention there, you'd need to eject.
blasdfaa commented
Take a look at the README: fastify/fastify-cli#options.
If you need to change the settings that are not mention there, you'd need to eject.
When using the export default function (fastify, opts) {}
from the app.js
I can't change the parameters that I can otherwise set via fastify({ /* options here */})
?
mcollina commented
No, you can't.