Skip to content

[services] strip services route prefix in python runtime#15097

Merged
ricardo-agz merged 15 commits intomainfrom
ricardo/be-438-remove-python-route-prefix
Feb 19, 2026
Merged

[services] strip services route prefix in python runtime#15097
ricardo-agz merged 15 commits intomainfrom
ricardo/be-438-remove-python-route-prefix

Conversation

@ricardo-agz
Copy link
Copy Markdown
Contributor

@ricardo-agz ricardo-agz commented Feb 18, 2026

  • Strip service route prefix in python runtime when services are auto-detected so app sees /ping instead of /_/backend/ping.
  • When routePrefix is manually set in vercel.json, we do not strip the route prefix
  • Sets SCRIPT_NAME with route prefix for WSGI
  • Sets root_path with route prefix for ASGI

Note: There is duplicate code in the vercel python runtime and vc_init_dev_asgi.py and vc_init_dev_wsgi.py. Ideally, we should consolidate vc_init_dev_asgi.py and vc_init_dev_wsgi.py into a single vc_init_dev.py (later PR)

Warning

High Risk Change

This PR adds route prefix stripping logic for Python runtime services, modifying request path handling in WSGI/ASGI environments which affects how requests are routed to user applications.

  • Adds new routePrefixSource field to Service type to distinguish configured vs auto-detected prefixes
  • Injects VERCEL_SERVICE_ROUTE_PREFIX_STRIP env var to enable path stripping in Python runtime
  • Modifies WSGI/ASGI scope handling to strip service prefix from request paths and set root_path/SCRIPT_NAME

Risk assessment for commit 1b738d7.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 18, 2026

🦋 Changeset detected

Latest commit: 1b738d7

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

This PR includes changesets to release 1 package
Name Type
@vercel/python-runtime 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
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 18, 2026

📦 CLI Tarball Ready

The Vercel CLI tarball for this PR is now available!

Quick Test

You can test this PR's CLI directly by running:

npx https://vercel-jpiv6gszh.vercel.sh/tarballs/vercel.tgz --help

Use in vercel.json

To use this CLI version in your project builds, add to your vercel.json:

{
  "build": {
    "env": {
      "VERCEL_CLI_VERSION": "vercel@https://vercel-jpiv6gszh.vercel.sh/tarballs/vercel.tgz"
    }
  }
}

Python Runtime Wheel

A Python runtime wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_RUNTIME_PYTHON="vercel-runtime @ https://vercel-jpiv6gszh.vercel.sh/tarballs/vercel_runtime-0.5.0.dev1771523077+1b738d7-py3-none-any.whl"

Remove the services route prefix in the Python runtime.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 18, 2026

🧪 Unit Test Strategy

Comparing: 8d69c721b738d7 (view diff)

Strategy: Code changed outside of a package - running all unit tests

⚠️ All unit tests will run because global code changes could impact all packages.

Affected packages - 40 (100%)
  1. @vercel-internals/get-package-json
  2. @vercel/backends
  3. @vercel/build-utils
  4. @vercel/cervel
  5. @vercel/cli-auth
  6. @vercel/client
  7. @vercel/config
  8. @vercel/detect-agent
  9. @vercel/edge
  10. @vercel/elysia
  11. @vercel/error-utils
  12. @vercel/express
  13. @vercel/fastify
  14. @vercel/firewall
  15. @vercel/frameworks
  16. @vercel/fs-detectors
  17. @vercel/functions
  18. @vercel/gatsby-plugin-vercel-builder
  19. @vercel/go
  20. @vercel/h3
  21. @vercel/hono
  22. @vercel/hydrogen
  23. @vercel/koa
  24. @vercel/nestjs
  25. @vercel/next
  26. @vercel/node
  27. @vercel/oidc
  28. @vercel/oidc-aws-credentials-provider
  29. @vercel/python
  30. @vercel/python-analysis
  31. @vercel/redwood
  32. @vercel/related-projects
  33. @vercel/remix-builder
  34. @vercel/routing-utils
  35. @vercel/ruby
  36. @vercel/rust
  37. @vercel/static-build
  38. @vercel/static-config
  39. examples
  40. vercel

Results

  • Unit tests: All affected packages will run unit tests
  • E2E tests: Running in parallel via E2E Tests workflow
  • Type checks: All affected packages will run type checks

This comment is automatically generated based on the affected testing strategy

@ricardo-agz ricardo-agz marked this pull request as ready for review February 18, 2026 04:16
@ricardo-agz ricardo-agz requested review from a team and agadzik as code owners February 18, 2026 04:16
Base automatically changed from ricardo/be-436-service-route-prefix-env to main February 18, 2026 18:07
@ricardo-agz ricardo-agz merged commit d44b1df into main Feb 19, 2026
390 of 400 checks passed
@ricardo-agz ricardo-agz deleted the ricardo/be-438-remove-python-route-prefix branch February 19, 2026 19:28
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.

5 participants