Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit 7bfaf6b

Browse files
committed
fix: only purge alias by default if the purgeCache function is called within a deployed function
linear ticket: http://linear.app/netlify/issue/RUN-1417/quantexa-or-content-not-invalidated-when-calling-purgecache
1 parent e01516d commit 7bfaf6b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib/purge_cache.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ export const purgeCache = async (options: PurgeCacheOptions = {}) => {
4848

4949
const payload: PurgeAPIPayload = {
5050
cache_tags: options.tags,
51-
deploy_alias: options.deployAlias,
5251
}
52+
53+
if ('deployAlias' in options) {
54+
payload.deploy_alias = options.deployAlias
55+
} else if (!env.NETLIFY_LOCAL) {
56+
payload.deploy_alias = env.NETLIFY_BRANCH
57+
}
58+
5359
const token = env.NETLIFY_PURGE_API_TOKEN || options.token
5460

5561
if (env.NETLIFY_LOCAL && !token) {

0 commit comments

Comments
 (0)