How a tiny typo in an angular service that got unnoticed, could become a bug several months later
# Typo done in august
.factory("Subtask", function($resource) {
- return $resource("/tasks/:task_id/subtasks/:id", {task_id: "@task_id", id: "@id"});
+ return $resource("tasks/:task_id/subtasks/:id", {task_id: "@task_id", id: "@id"});
}]);
But, it worked just fine.
But this week, we started using html5Mode
for our routes, which means our routing changed from /#/something/else
to /something/else
. And because of that, the request made by the service changed a little bit.
- POST /tasks/123/subtasks (201 Created)
+ POST /something/else/tasks/123/subtasks (404 Not found)
So since the request was always made when the url was /
before, the relative url was the same as an absolute one. But with html5Mode, the url when doing the request became /something/else
, so that's why it became a 404.
;)