@zadigetvoltaire/nuxt-well-known
@zadigetvoltaire/nuxt-well-known
ミドルウェアを使用してwell-known URIを追加するNuxtモジュール
Nuxt Well-Known
ミドルウェアを使用して
.well-known
URIを処理するNuxt (v3.x) モジュールhttps://www.iana.org/assignments/well-known-uris/well-known-uris.xhtml を参照してください。
⚠️ SSRモードのみでテスト済み(SSGおよびCSRではテストしていません)
Nuxt Well-Knownモジュールは、Nuxt Devtoolsと統合されています。
サポートされるWell-Known URI
security.txt
change-password
- コンテンツを使用した動的なルート:
content-uris
クイックセットアップ
- プロジェクトに
@zadigetvoltaire/nuxt-well-known
依存関係を追加します
# Using pnpm
pnpm add -D @zadigetvoltaire/nuxt-well-known
# Using yarn
yarn add --dev @zadigetvoltaire/nuxt-well-known
# Using npm
npm install --save-dev @zadigetvoltaire/nuxt-well-known
nuxt.config.ts
のmodules
セクションに@zadigetvoltaire/nuxt-well-known
を追加します
export default defineNuxtConfig({
modules: [
'@zadigetvoltaire/nuxt-well-known'
],
})
nuxtConfig.wellKnown
またはnuxtConfig.runtimeConfig.public.wellKnown
で設定を追加します
このモジュールは、2つの構成方法をサポートしています
- Nuxt設定のキー
wellKnown
で直接 - パブリックruntimeConfig内:環境変数で設定を上書きし、複数の環境を処理するのに便利
export default defineNuxtConfig({
...
wellKnown: {
devtools: true,
securityTxt: {
disabled: false,
contacts: ['me@example.com'],
expires: new Date('2025-02-03')
},
changePassword: {
disabled: false,
redirectTo: 'https://example.com/password-recovery'
}
}
...
runtimeConfig: {
public: {
wellKnown: {
devtools: true,
securityTxt: {
disabled: false,
contacts: ['me@example.com'],
expires: new Date('2025-02-03').toISOString() // ⚠️ in runtime config, `expires` should be a string
},
changePassword: {
disabled: false,
redirectTo: 'https://example.com/password-recovery'
}
}
}
}
})
モジュールオプション
interface ModuleOptions {
/**
* Enable Nuxt Devtools integration
*
* @default true
*/
devtools?: boolean
securityTxt?: SecurityTxtOptions,
changePassword?: ChangePasswordOptions,
contentUris?: ContentUriOptions[],
}
ミドルウェア
security.txt
このミドルウェアは、/.well-known/security.txt
URIで利用可能なsecurity.txt
ファイルを生成します。
モデルオプション
type SecurityTxtOptions = {
disabled?: boolean;
contacts: string[]; // https://www.rfc-editor.org/rfc/rfc9116#section-2.5.3
expires: string | Date; // https://www.rfc-editor.org/rfc/rfc9116#section-2.5.5
encryption?: string[]; // https://www.rfc-editor.org/rfc/rfc9116#section-2.5.4
acknowledgments?: string[]; // https://www.rfc-editor.org/rfc/rfc9116#section-2.5.1
preferredLanguages?: string[]; // https://www.rfc-editor.org/rfc/rfc9116#section-2.5.8
canonical?: string[]; // https://www.rfc-editor.org/rfc/rfc9116#section-2.5.2
policy?: string[]; // https://www.rfc-editor.org/rfc/rfc9116#section-2.5.7
hiring?: string[]; // https://www.rfc-editor.org/rfc/rfc9116#section-2.5.6
}
change-password
このミドルウェアは、/.well-known/change-password
のリクエストを設定されたターゲットURLにリダイレクトします。
type ChangePasswordOptions = {
disabled?: boolean;
redirectTo: string;
}
content-uris
このミドルウェアを使用すると、コンテンツを使用してURIを生成できます
type ContentUriOptions = {
disabled?: boolean;
path: string;
content: string;
}
例
// nuxt.config.ts
export default defineNuxtConfig({
modules: [
'@zadigetvoltaire/nuxt-well-known',
],
wellKnown: {
contentUris: [
{ path: 'apple-developer-merchantid-domain-association', content: 'merchantid' },
{ path: 'content-uri.txt', content: 'content-uri' }
]
}
})
レンダリング結果
https://example.com/.well-known/apple-developer-merchantid-domain-association
-->merchantid
https://example.com/.well-known/content-uri.txt
-->content-uri
これで完了です! NuxtアプリでNuxt Well-Knownを使用できます✨
コントリビューション
# Install dependencies, prepare apps & run dev server
make start
# Run dev server
pnpm dev
# Develop with playground, with bundled client ui
pnpm play:prod
# Run ESLint
pnpm lint
# Run Vitest
pnpm test
pnpm test:watch
新しいバージョンのリリース
- リリースコマンドを実行します
⚠ このコマンドはメインブランチでのみ実行する必要があります
このコマンドは以下を行います
- CHANGELOG.mdを生成し、リリースコミットとともにプッシュします
- パッケージのバージョンを上げます
- 新しいタグを作成してプッシュします
- ライブラリの公開パイプラインをトリガーするためのGitHubリリースを作成します
pnpm release
© Zadig&VoltaireはZV FRANCEの登録商標です