-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle nova config file in tools routing stubs #6106
Comments
It not clear what's the issue here, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example) |
Hi @crynobone This is the default protected function routes()
{
if ($this->app->routesAreCached()) {
return;
}
Nova::router(['nova', Authenticate::class, Authorize::class], 'world-creator')
->group(__DIR__.'/../routes/inertia.php');
Route::middleware(['nova', Authorize::class])
->prefix('nova-vendor/world-creator') // <--- Here is the problem
->group(__DIR__.'/../routes/api.php');
} I created a basic route inside my tool use MazLaboratory\WorldCreator\Http\Controllers\WorldCreator;
Route::put('/create', [WorldCreator::class, 'create']); And inside my export default {
data: () => ({
formData: {
world_name: '',
map_name: '',
maximum_players: undefined,
map_width: undefined,
map_height: undefined,
}
}),
methods: {
async createWorld() {
await Nova.request().put(`nova-vendor/world-creator/create`, this.formData)
.then(response => Nova.success(response.data))
.catch(error => Nova.error(error.response.data))
}
}
} Reading the Tool documentation and trusting the The final working code for my Route::middleware(['nova', Authorize::class])
->prefix(config('nova.path').'/nova-vendor/world-creator')
->group(__DIR__.'/../routes/api.php'); In my case, the |
|
!!!! Holy s... My bad! I looked into public packages to understand why they did not faced this problem or how did they solved it. // This vvv
Nova.request().put(`/nova-vendor/world-creator/create`, this.formData)
// Instead of this:
Nova.request().put(`nova-vendor/world-creator/create`, this.formData) |
Description:
When creating our fist Tool, the documentation states:
As expected, the stub for the Tools prefix the route group with the
/nova-vendor/tool-name
part.But, when using
Nova.request
, the confignova.path
(which defaults to/nova
) is prepended to the request, and I guess (not tested) that thenova.domain
is also supported by the javascript library.I suggest that the stub should include the config path and domain to avoid losing time to figure why we get a 404 with a basic routing file for our tool.
The text was updated successfully, but these errors were encountered: