File tree Expand file tree Collapse file tree 3 files changed +12
-26
lines changed Expand file tree Collapse file tree 3 files changed +12
-26
lines changed Original file line number Diff line number Diff line change 1
- import { redirect } from "react-router" ;
2
- import type { Route } from "../../+types/root" ;
1
+ import { redirect , type unstable_MiddlewareFunction } from "react-router" ;
3
2
4
- export const ensureSecure : Route . unstable_MiddlewareFunction = async (
5
- { request } ,
6
- next
7
- ) => {
3
+ export const ensureSecure : unstable_MiddlewareFunction = async ( {
4
+ request,
5
+ } ) => {
8
6
let proto = request . headers . get ( "x-forwarded-proto" ) ;
9
7
// this indirectly allows `http://localhost` because there is no
10
8
// "x-forwarded-proto" in the local server headers
@@ -13,7 +11,4 @@ export const ensureSecure: Route.unstable_MiddlewareFunction = async (
13
11
secureUrl . protocol = "https:" ;
14
12
throw redirect ( secureUrl . toString ( ) ) ;
15
13
}
16
- // FIXME: Update RR to auto-bubble the internal response if `next` isn't
17
- // called so we can omit the return value
18
- return next ( ) ;
19
14
} ;
Original file line number Diff line number Diff line change 1
- import { redirect } from "react-router" ;
2
- import type { Route } from "../../+types/root" ;
1
+ import { redirect , type unstable_MiddlewareFunction } from "react-router" ;
3
2
4
- export const removeTrailingSlashes : Route . unstable_MiddlewareFunction = async (
5
- { request } ,
6
- next
7
- ) => {
3
+ export const removeTrailingSlashes : unstable_MiddlewareFunction = async ( {
4
+ request,
5
+ } ) => {
8
6
let url = new URL ( request . url ) ;
9
7
if ( url . pathname . endsWith ( "/" ) && url . pathname !== "/" ) {
10
8
url . pathname = url . pathname . slice ( 0 , - 1 ) ;
11
9
throw redirect ( url . toString ( ) ) ;
12
10
}
13
- // FIXME: Update RR to auto-bubble the internal response if `next` isn't
14
- // called so we can omit the return value
15
- return next ( ) ;
16
11
} ;
Original file line number Diff line number Diff line change 1
- import type { Route } from "../../../+types/root " ;
1
+ import { type unstable_MiddlewareFunction } from "react-router " ;
2
2
import { checkUrl } from "./check-url" ;
3
3
import { getRedirects } from "./get-redirects" ;
4
4
@@ -15,15 +15,11 @@ import { getRedirects } from "./get-redirects";
15
15
*
16
16
* @param request Web Fetch Request to possibly redirect
17
17
*/
18
- export const handleRedirects : Route . unstable_MiddlewareFunction = async (
19
- { request } ,
20
- next
21
- ) => {
18
+ export const handleRedirects : unstable_MiddlewareFunction = async ( {
19
+ request,
20
+ } ) => {
22
21
let redirects = await getRedirects ( ) ;
23
22
let url = new URL ( request . url ) ;
24
23
let response = await checkUrl ( url . pathname , redirects ) ;
25
24
if ( response ) throw response ;
26
- // FIXME: Update RR to auto-bubble the internal response if `next` isn't
27
- // called so we can omit the return value
28
- return next ( ) ;
29
25
} ;
You can’t perform that action at this time.
0 commit comments