Skip to content

Commit ae595ae

Browse files
committed
Add route for /v1 path
At some point there will be an update to nginx that no longer strips the `/v1` from the path. When this happens, having this mount point in place will allow the fall through to the Catalyst app to continue. This fixes an issue where the Mojolicous application is unable to validate the specification for OpenAPI because the defined base path does not exist.
1 parent ade4ddf commit ae595ae

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/MetaCPAN/API.pm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,20 @@ sub _set_up_routes {
145145
$self->plugin( 'Minion::Admin' => { route => $admin->any('/minion') } );
146146
$self->plugin(
147147
'OpenAPI' => { url => $self->home->rel_file('root/static/v1.yml') } );
148+
149+
# This route is for when nginx gets updated to no longer strip the `/v1` path.
150+
# By retaining the `/v1` path the OpenAPI spec is picked up and passed
151+
# through Mojolicous. The `rewrite` parameter is stripping the `/v1` before
152+
# it is passed to Catalyst allowing the previous logic to be followed.
153+
$self->plugin(
154+
MountPSGI => {
155+
'/v1' => $self->home->child('app.psgi')->to_string,
156+
rewrite => 1
157+
}
158+
);
159+
160+
# XXX Catch cases when `v1` has been stripped by nginx until migration is complete
161+
# XXX then this path can be removed.
148162
$self->plugin(
149163
MountPSGI => { '/' => $self->home->child('app.psgi')->to_string } );
150164

0 commit comments

Comments
 (0)