Embed images and download files securely via API requests
- Download Base64 files
- Directive for embedding images (WIP)
- TypeScript support
- Add
nuxt-secure-filesdependency to your project:
npm install nuxt-secure-files- Add
nuxt-secure-filesmodule tonuxt.config.js:
export default {
// ...other config options
modules: ["nuxt-secure-files"];
}- (Optional) TypeScript support. Add
nuxt-secure-filesto thetypessection 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).