@@ -2,17 +2,15 @@ import React from "react"
2
2
import { useIdentityContext , SettingContext } from "../context"
3
3
import { Settings } from "react-netlify-identity"
4
4
5
-
6
-
7
- const isLocalhost = Boolean (
8
- window . location . hostname === 'localhost' ||
9
- // [::1] is the IPv6 localhost address.
10
- window . location . hostname === '[::1]' ||
11
- // 127.0.0.1/8 is considered localhost for IPv4.
12
- window . location . hostname . match (
13
- / ^ 1 2 7 (?: \. (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) ) { 3 } $ /
5
+ const isLocalhost =
6
+ window !== undefined &&
7
+ Boolean (
8
+ window . location . hostname === "localhost" ||
9
+ // [::1] is the IPv6 localhost address.
10
+ window . location . hostname === "[::1]" ||
11
+ // 127.0.0.1/8 is considered localhost for IPv4.
12
+ window . location . hostname . match ( / ^ 1 2 7 (?: \. (?: 2 5 [ 0 - 5 ] | 2 [ 0 - 4 ] [ 0 - 9 ] | [ 0 1 ] ? [ 0 - 9 ] [ 0 - 9 ] ? ) ) { 3 } $ / )
14
13
)
15
- ) ;
16
14
17
15
export function Providers ( ) {
18
16
const setting = React . useContext ( SettingContext )
@@ -23,7 +21,9 @@ export function Providers() {
23
21
if ( ! hasProviders ) return null
24
22
return (
25
23
< div className = "providersGroup" >
26
- { isLocalhost && < pre > ⚠️Testing providers on localhost won't work because OAuth redirects to your production site</ pre > }
24
+ { isLocalhost && (
25
+ < pre > ⚠️Testing providers on localhost won't work because OAuth redirects to your production site</ pre >
26
+ ) }
27
27
< hr className = "hr" />
28
28
< ProviderButton setting = { setting } provider = "Google" />
29
29
< ProviderButton setting = { setting } provider = "GitHub" />
0 commit comments