-
|
I am trying to override the initial Nova connexion 403 error page, but my scripts aren't getting loaded because of a 403 error. However, my script is correctly loaded when the user is authorized. Is there any way to load custom scripts regardless of the authorization? Below is my code to generate/load the script. resources/js/nova/custom.jsNova.booting((Vue, router) => {
Vue.component('CustomError403', require('./components/CustomError403'));
});app/Providers/NovaServiceProvider.phppublic function boot()
{
parent::boot();
Nova::script('custom', public_path('js/nova/custom.js'));
}webpack.mix.jsmix.js('resources/js/app.js', 'public/js')
.js('resources/js/nova/custom.js', 'public/js/nova')
.vue({ version: 3 })
.webpackConfig({
externals: {
vue: 'Vue',
},
})
.postCss('resources/css/app.css', 'public/css', [
//
]); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Is this for Nova 3 or Nova 4?
But |
Beta Was this translation helpful? Give feedback.
-
Here's how to achieve a 403 page override in Nova 4:
mix.js('resources/js/app.js', 'public/js')
.js('resources/js/nova/custom.js', 'public/js/nova') // Add this line.
.vue({ version: 3 })
.webpackConfig({
externals: {
vue: 'Vue',
},
})
.postCss('resources/css/app.css', 'public/css', [
//
]);
public function boot()
{
parent::boot();
// It is important to use the remoteScript method here in order to make the script load
// even when the user is not authorized to see the view.
Nova::remoteScript(asset('js/nova/custom.js'));
// ...rest of the code.
}
<template>
<!-- You can put your custom markup here. -->
</template>
<script>
import Guest from '../../../../vendor/laravel/nova/resources/js/layouts/Guest.vue'
export default {
name: 'Error403',
layout: Guest,
}
</script>
import Error403 from './pages/Error403';
Nova.booting((app, store) => {
Nova.inertia('Nova.Error403', Error403)
})
npm install @vue/babel-plugin-jsx --save-dev
Done! You should now see your custom 403 page instead of the default one. |
Beta Was this translation helpful? Give feedback.
Here's how to achieve a 403 page override in Nova 4:
app/Providers/NovaServiceProvider.phpboot method