Fix webhookUrl() to account for route prefixes#272
Conversation
- Add named routes to webhook registrations for proper prefix handling - Update webhookUrl() to use route() helper instead of manual URL construction - This ensures webhook URLs include route prefixes (e.g., api/) when routes are registered in prefixed route files - Maintains compatibility with route caching and Laravel conventions - Builds on previous fix that added workflow slug to signal URLs
- Add trailing comma in array parameter - Fix method chaining indentation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #272 +/- ##
===========================================
Coverage 100.00% 100.00%
Complexity 310 310
===========================================
Files 46 46
Lines 1288 1290 +2
===========================================
+ Hits 1288 1290 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes webhook URL generation to properly account for route prefixes by using Laravel's named route system. Previously, webhook URLs were manually constructed using the url() helper, which bypassed route prefixes defined in route files (e.g., api/). The fix adds named routes to webhook registrations and updates webhookUrl() to use the route() helper, ensuring generated URLs include any configured prefixes.
Key Changes:
- Webhook routes now registered with names following pattern
workflows.start.{slug}andworkflows.signal.{slug}.{signal} webhookUrl()method refactored to useroute()helper instead of manual URL construction- Tests updated to reflect new URL patterns and route registration behavior
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Webhooks.php | Added named route registration for start and signal webhook endpoints |
| src/Activity.php | Refactored webhookUrl() to use route() helper with named routes instead of manual URL construction |
| tests/Unit/WebhooksTest.php | Simplified test to mock route name registration instead of URI pattern matching |
| tests/Unit/ActivityTest.php | Added webhook route registration and updated assertions to match new URL patterns |
| tests/Fixtures/TestWorkflow.php | Added #[Webhook] attributes to class and cancel() method for test coverage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #270