Skip to content

Expose route asset URLs on middleware context (v5 backport)#16794

Closed
matthewp wants to merge 2 commits into
5-legacyfrom
context-assets-v5
Closed

Expose route asset URLs on middleware context (v5 backport)#16794
matthewp wants to merge 2 commits into
5-legacyfrom
context-assets-v5

Conversation

@matthewp
Copy link
Copy Markdown
Contributor

Changes

Backport of #16793 to v5.

  • Adds context.styles, context.scripts, and context.links to APIContext:
    • styles — inline CSS strings
    • links — external stylesheet URLs (resolved with base/assetsPrefix)
    • scripts — external script URLs (resolved with base/assetsPrefix)

Testing

  • 14 unit tests for the getRouteAssets() pure function.

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

🦋 Changeset detected

Latest commit: 7f3eca3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 448 packages
Name Type
astro Minor
@e2e/astro-linked-lib Patch
@e2e/actions-blog Patch
@e2e/actions-react-19 Patch
@e2e/astro-component Patch
@e2e/astro-envs Patch
@e2e/content-collections Patch
@e2e/csp-server-islands Patch
@e2e/css Patch
@test/custom-client-directives Patch
@e2e/dev-toolbar Patch
@e2e/error-cyclic Patch
@e2e/error-sass Patch
@e2e/errors Patch
@e2e/hydration-race Patch
@e2e/i18n Patch
@test/nested-style-bug-e22e Patch
@e2e/preact-compat-component Patch
@e2e/preact-component Patch
@e2e/preact-lazy-component Patch
@e2e/prefetch Patch
@e2e/react-component Patch
@e2e/server-islands-key Patch
@e2e/server-islands Patch
@e2e/solid-circular Patch
@e2e/solid-component Patch
@e2e/solid-recurse Patch
@e2e/svelte-component Patch
@e2e/e2e-tailwindcss Patch
@e2e/ts-resolution Patch
@e2e/view-transitions Patch
@e2e/vite-virtual-modules Patch
@e2e/vue-component Patch
@performance/md Patch
@performance/mdoc Patch
@performance/mdx Patch
@test/0-css Patch
fake-astro-library Patch
@test/actions Patch
@test/aliases-tsconfig-baseurl-only Patch
@test/ts-paths-no-baseurl Patch
@test/aliases-tsconfig Patch
@test/aliases Patch
@test/api-routes Patch
@test/asset-url-base Patch
@test/astro-pages Patch
@test/astro-assets-dir Patch
@test/astro-assets-prefix Patch
@test/astro-assets Patch
@test/astro-attrs Patch
@test/astro-basic Patch
@test/astro-check-errors Patch
@test/astro-check-no-errors Patch
@test/astro-check-watch Patch
@test/astro-children Patch
@test/astro-class-list Patch
@test/astro-client-only Patch
@test/astro-component-bundling Patch
@test/astro-component-code Patch
@test/astro-components Patch
@test/astro-cookies Patch
@test/astro-css-bundling-nested-layouts Patch
@test/astro-css-bundling Patch
@test/astro-dev-headers Patch
@test/astro-dev-http2 Patch
@test/astro-directives Patch
@test/astro-doctype Patch
@test/astro-dynamic Patch
@test/astro-env-content-collections Patch
@test/astro-env-required-public Patch
@test/astro-env-server-fail Patch
@test/astro-env-server-secret Patch
@test/astro-env Patch
@test/astro-envs Patch
@test/astro-expr Patch
@test/astro-external-files Patch
@test/astro-fallback Patch
@test/astro-generator Patch
@test/astro-get-static-paths Patch
@test/astro-global Patch
@test/astro-head Patch
@test/astro-info-versions Patch
@test/astro-jsx Patch
@test/astro-manifest-invalid Patch
@test/astro-manifest Patch
@test/astro-markdown-frontmatter-injection Patch
@test/astro-markdown-plugins Patch
@test/astro-markdown-remarkRehype Patch
@test/astro-markdown-skiki-default-color Patch
@test/astro-markdown-skiki-langs Patch
@test/astro-markdown-skiki-normal Patch
@test/astro-markdown-skiki-themes-custom Patch
@test/astro-markdown-skiki-themes-integrated Patch
@test/astro-markdown-skiki-wrap-false Patch
@test/astro-markdown-skiki-wrap-null Patch
@test/astro-markdown-skiki-wrap-true Patch
@test/astro-markdown-url Patch
@test/astro-markdown Patch
@test/astro-mode Patch
@test/astro-not-response Patch
@test/astro-object-style Patch
@test/astro-page-directory-url Patch
@test/astro-pagination-root Patch
@test/astro-pagination Patch
@test/astro-partial-html Patch
@test/astro-preview-headers Patch
@test/astro-public Patch
@test/astro-response Patch
@test/astro-scripts Patch
@test/astro-sitemap-rss Patch
@test/astro-slots-nested Patch
@test/astro-slots Patch
@test/concurrency Patch
@test/build-readonly-file Patch
@test/client-address-node Patch
@test/client-address Patch
@test/code-component Patch
@test/component-library Patch
@test/config-host Patch
@test/config-path Patch
@test/config-vite-css-target Patch
@test/config-vite Patch
@test/react-container Patch
@test/content-with-spaces-in-folder-name Patch
@example/content-collection-references Patch
@test/content-collections-base Patch
@test/content-collections-cache-invalidation Patch
@test/content-collections-empty-dir Patch
@test/content-collections-empty-md-file Patch
@test/content-collections-mutation Patch
@test/content-collections-number-id Patch
@test/content-collections-same-contents Patch
@test/content-collections-with-config-mjs Patch
@test/content-collections-with-config-mts Patch
@test/content-collections Patch
@test/content-intellisense Patch
@test/content-layer-markdoc Patch
@test/content-layer-remark-plugins Patch
@test/content-layer-rendering Patch
@test/content-layer Patch
@test/content-ssr-integration Patch
@test/content-static-paths-integration Patch
@test/content Patch
@test/core-image-base Patch
@test/core-image-data-url Patch
@test/core-image-deletion Patch
@test/core-image-errors Patch
@test/core-image-fs-config Patch
@test/core-image-remark-infersize Patch
@test/core-image-layout Patch
@test/core-image-remark-imgattr Patch
@test/core-image-ssg Patch
@test/core-image-ssr Patch
@test/core-image-svg-in-client Patch
@test/core-image-svg-optimized Patch
@test/core-image-svg Patch
@test/core-image-unconventional-settings Patch
@test/core-image Patch
@test/csp-adapter Patch
@test/csp-fonts Patch
@test/csp Patch
@test/csrf Patch
@test/css-assets Patch
@test/css-dangling-references Patch
@test/css-deduplication Patch
@test/css-double-bundle Patch
@test/css-import-as-inline Patch
@test/css-inline-stylesheets-2 Patch
@test/css-inline-stylesheets-3 Patch
@test/css-inline-stylesheets Patch
@test/css-no-code-split Patch
@test/custom-404-html Patch
@test/custom-404-injected-from-dep Patch
@test/custom-404-injected Patch
@test/custom-404-locals Patch
@test/custom-404-loop-case-1 Patch
@test/custom-404-loop-case-2 Patch
@test/custom-404-loop-case-3 Patch
@test/custom-404-loop-case-4 Patch
@test/custom-404-loop-case-5 Patch
@test/custom-404-md Patch
@test/custom-404-pkg Patch
@test/custom-404 Patch
@test/custom-500-failing Patch
@test/custom-500-middleware Patch
@test/custom-500 Patch
@test/custom-assets-name Patch
custom-fetch-error-pages Patch
@test/custom-renderer Patch
@test/data-collections-schema Patch
@test/data-collections Patch
@test/debug-component Patch
@test/dynamic-endpoint-collision Patch
@test/dynamic-route-build-file Patch
@test/dynamic-route-collision Patch
@test/entry-file-names Patch
@test/error-bad-js Patch
@test/error-build-location Patch
@test/error-non-error Patch
@test/extension-matching Patch
@test/feature-support-message-suppresion Patch
@test/fetch Patch
@test/fonts Patch
@test/astro-fontsource-package Patch
@test/get-static-paths-pages Patch
@test/glob-pages-css Patch
@test/head-injection Patch
@test/hmr-css Patch
@test/hoisted-imports Patch
@test/html-component Patch
@test/html-escape-bug Patch
@test/html-escape Patch
@test/html-page Patch
@test/html-slots Patch
@test/hydration-race Patch
@test/i18n-double-prefix Patch
@test/i18n-locale-index-format-file Patch
@test/i18n-routing-base Patch
@test/i18n-routing-dynamic Patch
@test/i18n-routing-fallback-index Patch
@test/i18n-routing-fallback-rewrite-filename Patch
@test/i18n-routing-fallback-rewrite-hybrid Patch
@test/i18n-routing-fallback-rewrite Patch
@test/i18n-routing-fallback Patch
@test/i18n-manual-with-default-middleware Patch
@test/i18n-routing-manual Patch
@test/i18n-routing-prefix-always Patch
@test/i18n-routing-prefix-other-locales Patch
@test/i18n-routing-preferred-language Patch
@test/i18n-routing-subdomain Patch
@test/i18n-routing Patch
@test/i18n-server-island Patch
@test/import-ts-with-js Patch
@test/impostor-md-file Patch
@test/integration-add-page-extension Patch
@test/integration-server-setup Patch
@test/large-array-solid Patch
@test/legacy-content-collections Patch
@test/legacy-data-collections Patch
@test/live-loaders Patch
@test/markdown Patch
@test/middleware-dev Patch
@test/middleware-full-ssr Patch
@test/middleware-no-user-middlewaqre Patch
@test/middleware-sequence-request-clone Patch
@test/middleware-sequence-rewrite Patch
@test/middleware-ssg Patch
@test/middleware-tailwind Patch
@test/middleware-virtual Patch
@test/minification-html Patch
@test/non-ascii-path Patch
@test/non-html-pages Patch
@test/page-format Patch
@test/page-level-styles Patch
@test/parallel-components Patch
@test/partials Patch
@test/passthrough-image-service Patch
@test/postcss Patch
@test/preact-compat-component Patch
@test/preact-component Patch
@test/public-base-404 Patch
@test/redirects-i18n Patch
@test/ssr-redirect Patch
@test/remote-css Patch
@test/request-signal Patch
@test/reroute Patch
@test/reuse-injected-entrypoint Patch
@test/rewrite-custom-404 Patch
@test/rewrite-dynamic-routing Patch
@test/rewrite-i18n-manual-routing Patch
@test/rewrite-issue13633 Patch
@test/rewrite-route-pattern Patch
@test/rewrite-runtime-error-custom500 Patch
@test/rewrite-runtime-error Patch
@test/reroute-server Patch
@test/rewrite-trailing-slash-never Patch
@test/rewrite-with-base Patch
@test/root-srcdir-css Patch
@test/route-manifest Patch
@test/routing-priority Patch
@test/scoped-style-strategy Patch
@test/server-islands-hybrid Patch
@test/server-islands-ssr Patch
@test/sessions Patch
@test/set-html Patch
@test/slots-preact Patch
@test/slots-react Patch
@test/slots-solid Patch
@test/slots-svelte Patch
@test/slots-vue Patch
@test/solid-component Patch
@test/sourcemap Patch
@test/space-in-folder-name Patch
@test/special-chars-in-component-imports Patch
@test/ssr-api-route Patch
@test/ssr-assets Patch
@test/ssr-dynamic Patch
@test/ssr-env Patch
@test/ssr-api-route-custom-404 Patch
@test/ssr Patch
@test/ssr-locals Patch
@test/ssr-manifest Patch
@test/ssr-markdown Patch
@test/ssr-params Patch
@test/ssr-partytown Patch
@test/ssr-prerender-chunks Patch
@test/ssr-prerender-get-static-paths Patch
@test/ssr-prerender Patch
@test/ssr-preview Patch
@test/ssr-request Patch
@test/ssr-response Patch
@test/ssr-hoisted-script Patch
@test/ssr-scripts Patch
@test/ssr-split-manifest Patch
@test/static-build-code-component Patch
@test/static-build-dir Patch
@test/static-build-frameworks Patch
@test/static-build-page-url-format Patch
@test/static-build-ssr Patch
@test/static-build Patch
@test/static-redirect Patch
@test/streaming Patch
@test/svelte-component Patch
@test/svg-deduplication Patch
@test/tailwindcss Patch
@e2e/third-party-astro Patch
@test/type-imports Patch
@test/unused-slot Patch
@test/url-import-suffix Patch
@test/user-route-priority Patch
@test/view-transitions Patch
@test/virtual-astro-file Patch
@test/vitest Patch
@test/vue-component Patch
@test/vue-jsx Patch
@test/vue-with-multi-renderer Patch
@test/with-endpoint-routes Patch
@test/with-subpath-no-trailing-slash Patch
@test/without-site-config Patch
@test/db-aliases Patch
@test/db-db-in-src Patch
@test/error-handling Patch
@test/db-integration-only Patch
@test/db-integration Patch
@test/db-libsql-remote Patch
@test/db-local-prod Patch
@test/db-no-apptoken Patch
@test/db-no-seed Patch
@test/recipes Patch
@test/db-static-remote Patch
eventbrite-from-scratch Patch
@test/alpinejs-basics Patch
@test/alpinejs-directive Patch
@test/alpinejs-plugin-script-import Patch
@test/astro-cloudflare-astro-dev-platform Patch
@test/astro-cloudflare-astro-env Patch
@test/astro-cloudflare-compile-image-service Patch
@test/astro-cloudflare-custom-entryfile Patch
@test/astro-cloudflare-external-image-service Patch
@test/astro-cloudflare-wasm Patch
@test/astro-cloudflare-no-output Patch
@test/astro-cloudflare-routes-json Patch
@test/astro-cloudflare-with-base Patch
@test/astro-cloudflare-with-solid-js Patch
@test/astro-cloudflare-with-svelte Patch
@test/astro-cloudflare-with-vue Patch
@test/astro-cloudflare-wrangler-preview-platform Patch
@test/markdoc-content-collections Patch
@test/headings-custom Patch
@test/headings Patch
@test/image-assets-custom Patch
@test/image-assets Patch
@test/markdoc-propagated-assets Patch
@test/markdoc-render-with-space Patch
@test/markdoc-render-html Patch
@test/markdoc-render-null Patch
@test/markdoc-render-partials Patch
@test/markdoc-render-simple Patch
@test/markdoc-render-typographer Patch
@test/markdoc-render-with-components Patch
@test/markdoc-render-with-config Patch
@test/markdoc-render-with-extends-components Patch
@test/markdoc-render-with-indented-components Patch
@test/markdoc-variables Patch
@test/mdx-css-head-mdx Patch
@test/image-remark-imgattr Patch
@test/mdx-frontmatter-injection Patch
@test/netlify-skew-protection Patch
@test/netlify-hosted-astro-project Patch
@test/nodejs-api-route Patch
@test/nodejs-badurls Patch
@test/nodejs-encoded Patch
@test/nodejs-errors Patch
@test/nodejs-headers Patch
@test/nodejs-image Patch
@test/locals Patch
@test/node-middleware Patch
@test/nodejs-prerender-404-500 Patch
@test/nodejs-prerender-error-page Patch
@test/nodejs-prerender Patch
@test/nodejs-preview-headers Patch
@test/redirects Patch
@test/node-sessions Patch
@test/node-static-headers Patch
@test/node-trailingslash Patch
@test/url Patch
@test/well-known-locations Patch
@test/react-component Patch
@test/sitemap-chunks Patch
@test/sitemap-dynamic Patch
@test/sitemap-ssr Patch
@test/sitemap-static Patch
@test/sitemap-trailing-slash Patch
conditional-rendering Patch
@test/astro-vercel-basic Patch
@test/astro-vercel-image Patch
@test/astro-vercel-integration-assets Patch
@test/vercel-isr Patch
@test/vercel-max-duration Patch
@test/vercel-edge-middleware-with-edge-file Patch
@test/vercel-edge-middleware-without-edge-file Patch
@test/astro-vercel-no-output Patch
@test/astro-vercel-prerendered-error-pages Patch
@test/astro-vercel-redirects-serverless Patch
@test/astro-vercel-redirects Patch
@test/vercel-server-islands Patch
@test/astro-vercel-serverless-prerender Patch
@test/astro-vercel-serverless-with-dynamic-routes Patch
@test/astro-vercel-static-assets Patch
@test/vercel-static-headers Patch
@test/astro-vercel-static Patch
@test/vercel-streaming Patch
@test/astro-vercel-with-web-analytics-enabled-output-as-static Patch
vercel-hosted-astro-project Patch
@test/vue-app-entrypoint-async Patch
@test/vue-app-entrypoint-css Patch
@test/vue-app-entrypoint-no-export-default Patch
@test/vue-app-entrypoint-relative Patch
@test/vue-app-entrypoint-src-absolute Patch
@test/vue-app-entrypoint Patch
@test/vue-basics Patch
vue-prop-types Patch
astro-benchmark Patch
@benchmark/adapter Major
@benchmark/timer Major
benchmark-build-hybrid Patch
benchmark-build-server Patch
benchmark-build-static Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added the semver: minor Change triggers a `minor` release label May 19, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@github-actions github-actions Bot added pkg: astro Related to the core `astro` package (scope) docs pr and removed semver: minor Change triggers a `minor` release labels May 19, 2026
@matthewp matthewp added the pr preview Apply this label to a PR to generate a preview release label May 19, 2026
@matthewp matthewp force-pushed the context-assets-v5 branch from cc0d473 to 6f53ad1 Compare May 19, 2026 18:44
@matthewp matthewp removed the pr preview Apply this label to a PR to generate a preview release label May 19, 2026
@github-actions github-actions Bot added the 🚨 action Modifies GitHub Actions label May 19, 2026
@matthewp matthewp added the pr preview Apply this label to a PR to generate a preview release label May 19, 2026
@github-actions github-actions Bot removed the pr preview Apply this label to a PR to generate a preview release label May 19, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 19, 2026

npm i https://pkg.pr.new/astro@16794

commit: 7f3eca3

@matthewp matthewp force-pushed the context-assets-v5 branch from 6f53ad1 to a4c7586 Compare May 19, 2026 20:12
@matthewp matthewp added the pr preview Apply this label to a PR to generate a preview release label May 19, 2026
@github-actions github-actions Bot removed the pr preview Apply this label to a PR to generate a preview release label May 19, 2026
@matthewp matthewp added the pr preview Apply this label to a PR to generate a preview release label May 19, 2026
@github-actions github-actions Bot removed the pr preview Apply this label to a PR to generate a preview release label May 19, 2026
@matthewp matthewp added the pr preview Apply this label to a PR to generate a preview release label May 20, 2026
@github-actions github-actions Bot removed the pr preview Apply this label to a PR to generate a preview release label May 20, 2026
@matthewp
Copy link
Copy Markdown
Contributor Author

Closing in favor of #16813

@matthewp matthewp closed this May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚨 action Modifies GitHub Actions docs pr pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant