I am always having problems with writing the right routes. I am usually getting 404’s without understanding exactly why, and kind of finding the route via trial and error.
For example, considering I have <body data-homeurl="<?= $site->url() ?>"> see this simplified jquery ajax call:
$.ajax({
  type: "POST",
  url: $("body").data("homeurl") + "/pop-artwork",
  data: {
    id: id,
    all_ids: all_ids,
  },
  success: function (res) {
    res = JSON.parse(res);
    $("#modal-1 .modal-body").html(res);
  },
  error: function (jqXHR, exception) {
    console.log(jqXHR);
  },
});
In my localhost, this is pointing to:
http://localhost/~jaume/dev/nb/en/pop-artwork
And this is my attempt at a route to match that url
[
    'pattern' => '(:any)/pop-artwork',
    'action'  => function () {
        $id = get('id');
        $all_ids = get('all_ids');
        try {
            return json_encode(snippet('pop-artwork', array('id' => $id, 'all_ids' => $all_ids), true));
        } catch (Exception $ex) {
            return $ex->getMessage();
        }
    }
],     
That results in a 404
I’ve also tried the following patterns, that as far as I understand, should work, but return 404 as well
'(en|es|ca)/pop-artwork'
'(:any)/(en|es|ca)/pop-artwork'
'(:all)pop-artwork'
So, is there any way to produce a list of the urls a route should match to via PHP?
And, in general what am I missing here?
Thank you