python config_error ai_generated true

404 Not Found: The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

ID: python/flask-blueprint-url-prefix-double-slash

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
0Evidence
2024-05-14First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2.x active — — —
3.x active — — —

Root Cause

Blueprint registered with url_prefix='/api/' and route '/items' produces '/api//items'; client requests '/api/items'.

generic

中文

蓝图以 url_prefix='/api/' 注册,路由为 '/items',生成 '/api//items';客户端请求 '/api/items'。

Workarounds

  1. 95% success
    app.register_blueprint(bp, url_prefix='/api')  # no trailing slash
  2. 85% success
    Print app.url_map to verify generated rules: print(app.url_map)

Dead Ends

Common approaches that don't work:

  1. 75% fail

    Does not fix the doubled slash.

  2. 70% fail

    Masks the real prefix bug and creates security surface.