René's URL Explorer Experiment


Title: Let global middleware declare the paths it runs on · Issue #808 · voidzero-dev/void · GitHub

Open Graph Title: Let global middleware declare the paths it runs on · Issue #808 · voidzero-dev/void

X Title: Let global middleware declare the paths it runs on · Issue #808 · voidzero-dev/void

Description: Version void 1.8.0, and main at 004624f Problem Every file in middleware/ runs on every request, so a middleware that only matters for one section has to test the path itself: // middleware/04.admin.ts const ADMIN_PATH = /^\/admin(\/|$)/...

Open Graph Description: Version void 1.8.0, and main at 004624f Problem Every file in middleware/ runs on every request, so a middleware that only matters for one section has to test the path itself: // middleware/04.admi...

X Description: Version void 1.8.0, and main at 004624f Problem Every file in middleware/ runs on every request, so a middleware that only matters for one section has to test the path itself: // middleware/04.admi...

Opengraph URL: https://github.com/voidzero-dev/void/issues/808

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Let global middleware declare the paths it runs on","articleBody":"### Version\n\n`void` 1.8.0, and `main` at 004624f\n\n### Problem\n\nEvery file in `middleware/` runs on every request, so a middleware that only matters for one section has to test the path itself:\n\n```ts\n// middleware/04.admin.ts\nconst ADMIN_PATH = /^\\/admin(\\/|$)/;\n\nexport default defineMiddleware(async (c, next) => {\n  if (!ADMIN_PATH.test(c.req.path)) return next();\n  // …\n});\n```\n\nVoid's own dashboard does the same in `platform/packages/dashboard/middleware/01.auth.ts`, with `PUBLIC_PATHS` and `PUBLIC_PREFIXES`.\n\nThat's only boilerplate, but having middleware at all also costs every static file its free request. `resolveAssetWorkerBypass()` in `packages/void/src/asset-worker-bypass.ts` gives up the bypass as soon as there's any middleware:\n\n```ts\nfacts.hasMiddleware ||\n```\n\nSo in a build with middleware, every hashed JS, CSS and image file starts the Worker, and each middleware runs for it. Any middleware that reads a session, KV or D1 has to skip asset paths by hand, or every asset waits on that read. Void can't tell which middleware might touch `/assets/`, so it has to assume all of them do.\n\n### Proposal\n\nLet a middleware file export the paths it runs on, in the same glob syntax as `run_worker_first`:\n\n```ts\n// middleware/04.admin.ts\nexport const matcher = ['/admin', '/admin/**'];\n\nexport default defineMiddleware(async (c, next) => {\n  // runs only for /admin and below\n});\n```\n\n- A file without `matcher` runs on every request, as today, so existing apps see no change.\n- `!` patterns exclude paths, as in `run_worker_first`, so a middleware that sets shared data for every page can still leave assets out with `['/**', '!/assets/**']`.\n- Files still run in filename order; one that doesn't match is skipped.\n- `hasMiddleware` becomes \"has middleware that can reach the assets folder\": if every file has a `matcher` and none of them can reach it, checked with `patternCanReachUnder()` as the bypass already does for route, page and auth patterns, the bypass stays on.\n\nMatching on the request path alone keeps it decidable at build time. A function form, like `matcher: (c) => …`, couldn't be checked against the assets folder, so it would have to keep the Worker in front.\n\n### Prior art\n\n- Next.js: `export const config = { matcher: [...] }` in `middleware.ts`, with path patterns and negative lookaheads, so `_next/static` can be left out.\n- TanStack Start: middleware attached to a route runs only for that route and below.\n- TanStack Router: `beforeLoad` on a layout route runs for its children only.\n","author":{"url":"https://github.com/karthickeyan-dev","@type":"Person","name":"karthickeyan-dev"},"datePublished":"2026-11-13T01:48:35Z","url":"https://github.com/voidzero-dev/void/issues/808"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:9543b17c-6793-1ded-3b86-e0b197b94c35
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idED58:26BE6B:1C3F843:266AB60:6AFB96DF
html-safe-nonce25030e811b6d9db222c2b9abd8202163affbcbdb2126e91ceabb9a0e08ed2e15
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDU4OjI2QkU2QjoxQzNGODQzOjI2NkFCNjA6NkFGQjk2REYiLCJ2aXNpdG9yX2lkIjoiNDc3ODgwODI5MTU0MDgzNDAxNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac735929d807756dc9592e99e2a3ca0f9045f0fcde82a71fdd82c0f4238c015766
hovercard-subject-tagissue:6362936450
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/voidzero-dev/void/808/issue_layout
twitter:imagehttps://opengraph.githubassets.com/525bd40affe005c7babb904f8396ab90939c6c1efcdb081ff84ce97c7a0ce58b/voidzero-dev/void/issues/808
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/525bd40affe005c7babb904f8396ab90939c6c1efcdb081ff84ce97c7a0ce58b/voidzero-dev/void/issues/808
og:image:altVersion void 1.8.0, and main at 004624f Problem Every file in middleware/ runs on every request, so a middleware that only matters for one section has to test the path itself: // middleware/04.admi...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekarthickeyan-dev
hostnamegithub.com
expected-hostnamegithub.com
None4f01efe06174a5ba6342fd58e42d02295e0675bedbb465d6bef2dbaec8e46556
turbo-cache-controlno-preview
go-importgithub.com/voidzero-dev/void git https://github.com/voidzero-dev/void.git
octolytics-dimension-user_id149750581
octolytics-dimension-user_loginvoidzero-dev
octolytics-dimension-repository_id1164437080
octolytics-dimension-repository_nwovoidzero-dev/void
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1164437080
octolytics-dimension-repository_network_root_nwovoidzero-dev/void
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasea52db8866b6543b4e83730cd6a6b1360f1a9e4dc
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/voidzero-dev/void/issues/808#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fvoidzero-dev%2Fvoid%2Fissues%2F808
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fvoidzero-dev%2Fvoid%2Fissues%2F808
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=voidzero-dev%2Fvoid
Reloadhttps://github.com/voidzero-dev/void/issues/808
Reloadhttps://github.com/voidzero-dev/void/issues/808
Reloadhttps://github.com/voidzero-dev/void/issues/808
voidzero-devhttps://github.com/voidzero-dev
voidhttps://github.com/voidzero-dev/void
Codehttps://github.com/voidzero-dev/void
Issues31 (31)https://github.com/voidzero-dev/void/issues
Pull requests16 (16)https://github.com/voidzero-dev/void/pulls
Discussionshttps://github.com/voidzero-dev/void/discussions
Actionshttps://github.com/voidzero-dev/void/actions
Security and qualityhttps://github.com/voidzero-dev/void/security
Insightshttps://github.com/voidzero-dev/void/pulse
https://github.com/voidzero-dev/void
New issuehttps://github.com/login?return_to=https://github.com/voidzero-dev/void/issues/808
New issuehttps://github.com/login?return_to=https://github.com/voidzero-dev/void/issues/808
Let global middleware declare the paths it runs onhttps://github.com/voidzero-dev/void/issues/808#top
https://github.com/karthickeyan-dev
karthickeyan-devhttps://github.com/karthickeyan-dev
on Nov 13, 2026https://github.com/voidzero-dev/void/issues/808#issue-6362936450
004624fhttps://github.com/voidzero-dev/void/commit/004624f7e303185610b9af37331bb6fb5362cc86
https://github.com/yangshun
yangshunhttps://github.com/yangshun
on Nov 13, 2026https://github.com/voidzero-dev/void/issues/808#issuecomment-6841922565
Sign up for freehttps://github.com/signup?return_to=https://github.com/voidzero-dev/void/issues/808
Sign in to commenthttps://github.com/login?return_to=https://github.com/voidzero-dev/void/issues/808
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.