Skip to content

Commit 8c2d132

Browse files
committed
feat: add ability to use server as staging only
1 parent affcd75 commit 8c2d132

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

example/server/app.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ env_variables:
55
FILESET_BASE_URL: 'staging.example.com'
66
FILESET_DEFAULT_BRANCH: main
77
FILESET_SITE: default
8+
FILESET_STAGING_ONLY: ''
89
includes:
910
- secrets.yaml
1011
handlers:

src/server.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,14 @@ export function parseHostname(
117117
const cleanBaseUrl = options.baseUrl
118118
? options.baseUrl.replace(/^(https?):\/\//, '').split(':')[0]
119119
: '';
120-
const isLive = cleanHostname === cleanBaseUrl;
120+
const isProdHostname = cleanHostname === cleanBaseUrl;
121121
// Staging, run through supported prefixes.
122122
if (
123-
(options.baseUrl && cleanHostname.includes(cleanBaseUrl) && !isLive) ||
123+
(options.baseUrl &&
124+
cleanHostname.includes(cleanBaseUrl) &&
125+
!isProdHostname) ||
124126
options.hostname.includes('.localhost') ||
125-
(options.hostname.includes('-dot-') && !isLive)
127+
(options.hostname.includes('-dot-') && !isProdHostname)
126128
) {
127129
// site-ref
128130
// site-ref-with-dashes
@@ -245,7 +247,9 @@ export function createApp(siteId: string) {
245247

246248
// Access control check for staging environments.
247249
// TODO: Make the `isLive` check work with scheduled branches.
248-
const isLive = defaults.LIVE_BRANCHES.includes(manifest.branch);
250+
const stagingOnly = Boolean(process.env.FILESET_STAGING_ONLY);
251+
const isLive =
252+
defaults.LIVE_BRANCHES.includes(manifest.branch) && !stagingOnly;
249253
if (!isLive) {
250254
// If the webui isn't enabled, only live filesets are served. All other
251255
// paths are disabled.

0 commit comments

Comments
 (0)