Skip to content

Commit d85c4fb

Browse files
committed
Add rerouting for some undefined paths.
1 parent cf5ccea commit d85c4fb

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/App.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import React from 'react';
22
import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom';
33

4-
import { API_VERSION_1, API_VERSION_2 } from './config';
4+
import { API_VERSION_1, API_VERSION_2, DEFAULT_PATH } from './config';
55
import DefaultApiRoute from './graphiql/DefaultApiRoute';
66
import Version1ApiRoute from './graphiql/Version1ApiRoute';
77
import Version2ApiRoute from './graphiql/Version2ApiRoute';
88

99
export default () => {
1010
return (
11-
<BrowserRouter basename="/graphiql">
11+
<BrowserRouter>
1212
<Routes>
13-
<Route path="/" exact element={<Navigate to="/hsl" />} />
14-
<Route path="/:router" element={<DefaultApiRoute />}>
13+
<Route path="*" element={<Navigate to={DEFAULT_PATH} />} />
14+
<Route path="/graphiql/:router" element={<DefaultApiRoute />}>
1515
<Route
16-
path={`/:router/${API_VERSION_1}`}
16+
path={`/graphiql/:router/${API_VERSION_1}`}
1717
element={<Version1ApiRoute />}
1818
/>
1919
<Route
20-
path={`/:router/${API_VERSION_2}/:dialect/:dialectVersion`}
20+
path={`/graphiql/:router/${API_VERSION_2}/:dialect/:dialectVersion`}
2121
element={<Version2ApiRoute />}
2222
/>
2323
</Route>

src/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export const API_VERSION_1 = 'v1';
22
export const API_VERSION_2 = 'v2';
33
export const DIALECT_VERSION_1 = 'v1';
44
export const PRODUCTION_API_URL = 'api.digitransit.fi';
5+
export const DEFAULT_PATH = '/graphiql/hsl';
56
export const API_TYPE = Object.freeze({
67
DEV: 'dev',
78
PROD: 'prod',

0 commit comments

Comments
 (0)