Embed images and download files securely via API requests
- Download Base64 files
- Directive for embedding images (WIP)
- TypeScript support
- Add
nuxt-secure-files
dependency to your project:
npm install nuxt-secure-files
- Add
nuxt-secure-files
module tonuxt.config.js
:
export default {
// ...other config options
modules: ["nuxt-secure-files"];
}
- (Optional) TypeScript support. Add
nuxt-secure-files
to thetypes
section oftsconfig.json
:
{
"compilerOptions": {
"types": ["nuxt-secure-files"]
}
}
- Make sure Axios is setup, so the Authorization request header is sent. Example:
const axiosPlugin: Plugin = ({ $axios }): void => {
$axios.onRequest((config: AxiosRequestConfig): void => {
config.headers.Authorization = 'Bearer XXXXXXXXXXXXXXXX'
})
}
export default axiosPlugin
- Use
$secDownload
:
{
methods: {
downloadFile() {
this.$secDownload('/api/file/xx', 'file_xx.pdf');
}
}
}
See the LICENSE file for license rights and limitations (MIT).