[APPS] Fix dev backend query API origin#347
Draft
sdkennedy2 wants to merge 1 commit intomasterfrom
Draft
Conversation
Collaborator
Author
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation
Running a high-code app dev server with the default
dd-auth --actions-api -- npm run devwrapper currently gives the dev middleware credentials forDD_SITE=datadoghq.com. Backend function execution then sendspreview-asyncrequests tohttps://datadoghq.com/api/v2/app-builder/queries/preview-async, which CloudFront rejects because the bare site is not an API origin for POST requests.Changes
Normalize app-builder query execution URLs in the apps dev-server middleware before calling Datadog. Raw Datadog sites like
datadoghq.com, staging sites likedatad0g.com, and regional sites likeus5.datadoghq.comnow resolve to theirapi.*origin. Explicitapi.*values are preserved, andapp.*values are converted to the correspondingapi.*origin.This affects only local dev backend-function execution through
/__dd/executeAction; production iframe execution and asset upload behavior are unchanged.QA Instructions
~/.yarn/switch/bin/yarn workspace @dd/apps-plugin typecheck~/.yarn/switch/bin/yarn eslint packages/plugins/apps/src/vite/dev-server.ts packages/plugins/apps/src/vite/dev-server.test.ts~/.yarn/switch/bin/yarn workspace @dd/tests test:unit packages/plugins/apps/src/vite/dev-server.test.ts --runInBand@datadog/vite-plugininto/Users/scott.kennedy/dd/test-apps/testapp-may-7, rebuilt it, and verifieddd-auth --actions-api -- npm run devcan execute a backendlistHostsfunction. The dev log now callshttps://api.datadoghq.com/api/v2/app-builder/queries/preview-asyncand the local/__dd/executeActionrequest returns200.Blast Radius
This changes the API origin used by high-code app local dev-server backend function execution. The risk is limited to local development requests that proxy backend functions through Datadog's app-builder query APIs.
Documentation