File tree Expand file tree Collapse file tree 6 files changed +36
-3
lines changed Expand file tree Collapse file tree 6 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -13,3 +13,7 @@ SENTRY_DSN="your-dsn"
13
13
GITHUB_CLIENT_ID = " MOCK_GITHUB_CLIENT_ID"
14
14
GITHUB_CLIENT_SECRET = " MOCK_GITHUB_CLIENT_SECRET"
15
15
GITHUB_TOKEN = " MOCK_GITHUB_TOKEN"
16
+
17
+ # set this to false to prevent search engines from indexing the website
18
+ # default to allow indexing for seo safety
19
+ ALLOW_INDEXING = " true"
Original file line number Diff line number Diff line change @@ -181,11 +181,13 @@ function Document({
181
181
nonce,
182
182
theme = 'light' ,
183
183
env = { } ,
184
+ allowIndexing = true ,
184
185
} : {
185
186
children : React . ReactNode
186
187
nonce : string
187
188
theme ?: Theme
188
189
env ?: Record < string , string >
190
+ allowIndexing ?: boolean
189
191
} ) {
190
192
return (
191
193
< html lang = "en" className = { `${ theme } h-full overflow-x-hidden` } >
@@ -194,6 +196,9 @@ function Document({
194
196
< Meta />
195
197
< meta charSet = "utf-8" />
196
198
< meta name = "viewport" content = "width=device-width,initial-scale=1" />
199
+ { allowIndexing ? null : (
200
+ < meta name = "robots" content = "noindex, nofollow" />
201
+ ) }
197
202
< Links />
198
203
</ head >
199
204
< body className = "bg-background text-foreground" >
@@ -219,10 +224,16 @@ function App() {
219
224
const matches = useMatches ( )
220
225
const isOnSearchPage = matches . find ( m => m . id === 'routes/users+/index' )
221
226
const searchBar = isOnSearchPage ? null : < SearchBar status = "idle" />
227
+ const allowIndexing = data . ENV . ALLOW_INDEXING !== 'false'
222
228
useToast ( data . toast )
223
229
224
230
return (
225
- < Document nonce = { nonce } theme = { theme } env = { data . ENV } >
231
+ < Document
232
+ nonce = { nonce }
233
+ theme = { theme }
234
+ allowIndexing = { allowIndexing }
235
+ env = { data . ENV }
236
+ >
226
237
< div className = "flex h-screen flex-col justify-between" >
227
238
< header className = "container py-6" >
228
239
< nav className = "flex flex-wrap items-center justify-between gap-4 sm:flex-nowrap md:gap-8" >
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ const schema = z.object({
16
16
GITHUB_CLIENT_ID : z . string ( ) . default ( 'MOCK_GITHUB_CLIENT_ID' ) ,
17
17
GITHUB_CLIENT_SECRET : z . string ( ) . default ( 'MOCK_GITHUB_CLIENT_SECRET' ) ,
18
18
GITHUB_TOKEN : z . string ( ) . default ( 'MOCK_GITHUB_TOKEN' ) ,
19
+ ALLOW_INDEXING : z . enum ( [ 'true' , 'false' ] ) . optional ( ) ,
19
20
} )
20
21
21
22
declare global {
@@ -50,6 +51,7 @@ export function getEnv() {
50
51
return {
51
52
MODE : process . env . NODE_ENV ,
52
53
SENTRY_DSN : process . env . SENTRY_DSN ,
54
+ ALLOW_INDEXING : process . env . ALLOW_INDEXING ,
53
55
}
54
56
}
55
57
Original file line number Diff line number Diff line change @@ -67,6 +67,14 @@ Prior to your first deployment, you'll need to do a few things:
67
67
> [ 1Password] ( https://1password.com/password-generator ) to generate a random
68
68
> secret, just replace ` $(openssl rand -hex 32) ` with the generated secret.
69
69
70
+ - Add a ` ALLOW_INDEXING ` with ` false ` value to your non-production fly app
71
+ secrets, this is to prevent duplicate content from being indexed multiple
72
+ times by search engines. To do this you can run the following commands:
73
+
74
+ ``` sh
75
+ fly secrets set ALLOW_INDEXING=false --app [YOUR_APP_NAME]-staging
76
+ ```
77
+
70
78
6 . Create production database:
71
79
72
80
Create a persistent volume for the sqlite database for both your staging and
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ async function setupDeployment({ rootDirectory }) {
160
160
await $I `fly apps create ${ APP_NAME } `
161
161
162
162
console . log ( `🤫 Setting secrets in apps` )
163
- await $I `fly secrets set SESSION_SECRET=${ getRandomString32 ( ) } INTERNAL_COMMAND_TOKEN=${ getRandomString32 ( ) } HONEYPOT_SECRET=${ getRandomString32 ( ) } --app ${ APP_NAME } -staging`
163
+ await $I `fly secrets set SESSION_SECRET=${ getRandomString32 ( ) } INTERNAL_COMMAND_TOKEN=${ getRandomString32 ( ) } HONEYPOT_SECRET=${ getRandomString32 ( ) } ALLOW_INDEXING=false --app ${ APP_NAME } -staging`
164
164
await $I `fly secrets set SESSION_SECRET=${ getRandomString32 ( ) } INTERNAL_COMMAND_TOKEN=${ getRandomString32 ( ) } HONEYPOT_SECRET=${ getRandomString32 ( ) } --app ${ APP_NAME } `
165
165
166
166
console . log (
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ installGlobals()
16
16
17
17
const MODE = process . env . NODE_ENV ?? 'development'
18
18
const IS_PROD = MODE === 'production'
19
- const IS_DEV = MODE === "development"
19
+ const IS_DEV = MODE === 'development'
20
+ const ALLOW_INDEXING = process . env . ALLOW_INDEXING !== 'false'
20
21
21
22
const createRequestHandler = IS_PROD
22
23
? Sentry . wrapExpressCreateRequestHandler ( _createRequestHandler )
@@ -205,6 +206,13 @@ async function getBuild() {
205
206
return build as unknown as ServerBuild
206
207
}
207
208
209
+ if ( ! ALLOW_INDEXING ) {
210
+ app . use ( ( _ , res , next ) => {
211
+ res . set ( 'X-Robots-Tag' , 'noindex, nofollow' )
212
+ next ( )
213
+ } )
214
+ }
215
+
208
216
app . all (
209
217
'*' ,
210
218
createRequestHandler ( {
You can’t perform that action at this time.
0 commit comments