AdonisJS single route won't open

292 Views Asked by At

I've made this project with AdonisJS, this is PlaceController file content:

async create({
    view
  }) {
    return view.render('places.new')
  }

and this is view file path: views/places/new.edge which is a simple static HTML file.

and the routes.js file content:

Route.get('admin/places/new', 'PlaceController.create')

when I enter the URL in browser, the URL just disappears.the problem solves by removing admin from route. Is there a bug in this framework or am I doing something wrong?

1

There are 1 best solutions below

0
On BEST ANSWER

So problem solved. another Route caused this problem. it was

Route.get('admin/places/:id', 'PlaceController.edit').middleware(['admin'])
Route.get('admin/places/new/', 'PlaceController.create').middleware(['admin'])

changed the order to:

Route.get('admin/places/new/', 'PlaceController.create').middleware(['admin'])
Route.get('admin/places/:id', 'PlaceController.edit').middleware(['admin'])

now it works.