Skip to content

Fix /myshifts route being incorrectly matched as shift ID - #499

Open
AngeloZois wants to merge 1 commit into
mainfrom
AngeloZois/fix/invalid-shift-id
Open

Fix /myshifts route being incorrectly matched as shift ID#499
AngeloZois wants to merge 1 commit into
mainfrom
AngeloZois/fix/invalid-shift-id

Conversation

@AngeloZois

Copy link
Copy Markdown
Collaborator

Summary

Fixes an issue where the Employer Dashboard was unable to load shifts because the /api/v1/shifts/myshifts endpoint was being incorrectly handled by the dynamic /:id route.

Problem

When the Employer Dashboard requested /api/v1/shifts/myshifts, Express matched myshifts as the :id parameter. The backend then attempted to validate myshifts as a MongoDB ObjectId and returned a 400 Invalid id response.

Fix

Moved the /myshifts route above the /:id route in shift.routes.js so the specific route is matched before the dynamic ID route.

Testing

  • Rebuilt the backend Docker container.
  • Tested the Employer login and dashboard locally.
  • Confirmed /myshifts now loads successfully.
  • Confirmed the Employer Dashboard displays the seeded shifts instead of the Invalid id error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant