Skip to content

Tracking plugin returns 405 Method Not Allowed in the browser console #9272

@ichimiya1234

Description

@ichimiya1234

CKAN version

2.11.4

Describe the bug

An error appears in the browser console like this.

Failed to load resource: the server responded with a status of 405 (METHOD NOT ALLOWED) /_tracking:1

Steps to reproduce

Steps to reproduce the behavior:
CKAN version: 2.11.4
Nginx version: 1.24.0
uWSGI version: 2.0.24
Python version: 3.11.7
Flask version: 3.0.3

Having following extensions installed:

  • googleanalytics
  • activity
  • stats
  • image_view
  • text_view
  • datatables_view
  • webpage_view
  • pdf_view
  • geo_view
  • officedocs_view
  • datapusher
  • datastore
  • resource_proxy
  • geojson_view
  • shp_view
  • bodik_theme
  • tracking
  • feedback
ckan.plugins = googleanalytics activity stats image_view text_view datatables_view webpage_view pdf_view geo_view officedocs_view datapusher datastore resource_proxy geojson_view shp_view bodik_theme tracking feedback

Expected behavior

Without causing a 405 error, the tracking works correctly.
Strangely, although Flask reports an error, there is no issue with the tracking count or its operation.

Additional details

2026-02-24 04:25:49,642 INFO  [ckan.config.middleware.flask_app] 405 Method Not Allowed: The method is not allowed for the requested URL.
2026-02-24 04:25:49,648 DEBUG [ckanext.tracking.middleware] Tracking page for /dataset/test_excel_xls
2026-02-24 04:25:49,650 INFO  [ckan.config.middleware.flask_app]  405 /_tracking render time 0.010 seconds

Temporary workaround

ckanext/tracking/plugin.py

class TrackingPlugin(p.SingletonPlugin):
    p.implements(p.IClick)
    p.implements(p.IConfigurer)
    p.implements(p.IMiddleware, inherit=True)
    p.implements(p.IPackageController, inherit=True)
    p.implements(p.ITemplateHelpers)
 p.implements(p.IBlueprint)
 
 def get_blueprint(self):
  from ckanext.tracking.views import tracking_bp
  return tracking_bp 

Create a new file ckanext/tracking/views.py

from flask import Blueprint

tracking_bp = Blueprint('tracking',__name__)

def tracking_endpoint():
 return '', 200

tracking_bp.add_url_rule(
    '/_tracking',
    'tracking',
    tracking_endpoint,
    methods=['POST']
)

By adding the above, you can prevent the 405 error from appearing.

ISSUE with a similar problem: #9009

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions