Skip to content

PLIP: Deprecate Accept-Header-Based REST API Routing in Favor of /++api++/ URLs #4245

@mamico

Description

@mamico

PLIP (Plone Improvement Proposal)

Responsible Persons

Proposer: Mauro Amico @mamico

Seconder:

Abstract

This PLIP proposes to fully deprecate the REST API routing mechanism based on the Accept: application/json HTTP header.

While both header-based and URL-based (/++api++/) REST API access are currently supported, this proposal aims to make /++api++/ the only supported mechanism for REST API access in Plone.

The header-based behavior will be deprecated and eventually disabled by default, with an optional environment variable allowing legacy installations to re-enable it.

Motivation

Plone currently supports two parallel mechanisms for REST API access:

  1. Implicit detection based on the Accept: application/json header
  2. Explicit URL-based routing using the /++api++/ prefix

Maintaining both mechanisms introduces ambiguity and complexity in routing, caching, security, and deployment configurations. (i.e. plone/plone.rest#77)

The header-based mechanism in particular has several drawbacks:

  • Implicit behavior depending on client headers rather than explicit URLs
  • Increased complexity in traversal and middleware logic
  • Difficulties in configuring reverse proxies and caching layers
  • Harder to apply different security, rate-limiting, and caching policies

The /++api++/ prefix already provides a clear and explicit separation of concerns
and aligns with common best practices for API design.

Assumptions

  • Both routing mechanisms are currently active and supported
  • /++api++/ is considered the canonical and future-proof REST API entry point
  • Legacy behavior must be explicitly opt-in once deprecated

Proposal & Implementation

  1. Canonical REST API Entry Point

    • /++api++/ becomes the only supported REST API URL namespace
  2. Legacy Opt-In via Environment Variable

    • An environment variable (e.g. PLONE_ENABLE_ACCEPT_HEADER_RESTAPI)
      can be used to re-enable the legacy behavior
    • This allows existing integrations more time to migrate

Implementation Notes

  • Document the migration path for integrators and frontend applications
  • Update tests to ensure no REST API view is reachable without /++api++/
    when the legacy flag is disabled

Deliverables

  • plone.rest/plone.restapi changes to disable Accept-based routing by default
  • Environment-variable-based legacy compatibility switch
  • Updated documentation and upgrade notes
  • Test coverage for both default and legacy modes

Risks

  • Existing clients (eg. volto sites, volto addons, ...) relying on Accept: application/json will break

These risks are mitigated by:

  • A clear deprecation phase
  • An explicit opt-in legacy mechanism
  • Early communication and documentation

Participants

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions