Skip to content

Allow callbacks to have a relative URL#1991

Merged
255kb merged 1 commit intomainfrom
feature/1730-relative-callbacks
Dec 3, 2025
Merged

Allow callbacks to have a relative URL#1991
255kb merged 1 commit intomainfrom
feature/1730-relative-callbacks

Conversation

@255kb
Copy link
Member

@255kb 255kb commented Dec 2, 2025

  • add new serverHost property to the server configuration to allow resolution override (especially in the cloud)
  • add new headers when doing internal calls to make debugging easier and prevent infinite loops

Closes #1730

Technical implementation details

Checklist

  • data migration added (@mockoon/commons)
  • commons lib tests added (@mockoon/commons)
  • commons-server lib tests added (@mockoon/commons-server)
  • CLI tests added (@mockoon/cli)
  • desktop UI automated tests added (@mockoon/app)

Closes #{issue_number}

Copilot AI review requested due to automatic review settings December 2, 2025 15:38
@255kb 255kb marked this pull request as draft December 2, 2025 15:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for relative URLs in callbacks, allowing them to reference routes within the same Mockoon server. The implementation includes a new serverHost configuration option (though not yet utilized), infinite loop prevention for callbacks, and adds debugging headers for internal callback invocations. The Angular component is also refactored to use the modern @if/@for control flow syntax.

Key Changes

  • Added serverHost property to ServerOptions to enable custom host override for callback URL resolution
  • Implemented relative URL detection and resolution for callbacks with automatic protocol and port addition
  • Added infinite loop prevention and debugging headers for internal callback invocations

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
packages/commons/src/models/server.model.ts Added serverHost optional property to ServerOptions for custom host configuration
packages/commons-server/src/libs/server/server.ts Refactored callback execution with relative URL support, infinite loop prevention, and enhanced debugging headers
packages/app/src/renderer/app/components/environment-callbacks/environment-callbacks.component.ts Removed unused Angular imports (NgIf, NgFor) as template migrated to new control flow
packages/app/src/renderer/app/components/environment-callbacks/environment-callbacks.component.html Migrated from *ngIf/*ngFor to modern @if/@for` syntax and updated placeholder text for URL input

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@255kb 255kb force-pushed the feature/1730-relative-callbacks branch from 157780f to ec07491 Compare December 2, 2025 15:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@255kb 255kb force-pushed the feature/1730-relative-callbacks branch from ec07491 to 597b141 Compare December 3, 2025 10:45
@255kb 255kb marked this pull request as ready for review December 3, 2025 10:45
- add new  publicHostUrl property to the server configuration to allow resolution override (especially in the cloud)
- add new headers when doing internal calls to make debugging easier and prevent infinite loops
- add new CLI flag --public-base-url

Closes #1730
@255kb 255kb force-pushed the feature/1730-relative-callbacks branch from 597b141 to e7316e3 Compare December 3, 2025 10:48
@255kb 255kb merged commit dcda52e into main Dec 3, 2025
15 checks passed
@255kb 255kb deleted the feature/1730-relative-callbacks branch December 3, 2025 12:54
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.

Allow relative path in callbacks to call self

2 participants