diff options
author | 2022-04-11 21:30:47 +0200 | |
---|---|---|
committer | 2022-04-11 12:30:47 -0700 | |
commit | 9f248b0563828db0e01e685aac177eaf8107906e (patch) | |
tree | 4ad148a351f4e6392c1b7119a8b225303af1aecc /packages/integrations/netlify/src | |
parent | 771127ea294fb297c080b2bb3e74b433043b90f4 (diff) | |
download | astro-9f248b0563828db0e01e685aac177eaf8107906e.tar.gz astro-9f248b0563828db0e01e685aac177eaf8107906e.tar.zst astro-9f248b0563828db0e01e685aac177eaf8107906e.zip |
Make Netlify adapter actually append redirects (#3079)
Diffstat (limited to 'packages/integrations/netlify/src')
-rw-r--r-- | packages/integrations/netlify/src/index.ts | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/packages/integrations/netlify/src/index.ts b/packages/integrations/netlify/src/index.ts index 60aad4b79..c473de67a 100644 --- a/packages/integrations/netlify/src/index.ts +++ b/packages/integrations/netlify/src/index.ts @@ -53,11 +53,10 @@ ${pattern} /.netlify/functions/${entryFile} 200`; } } - if (fs.existsSync(_redirects)) { - await fs.promises.appendFile(_redirectsURL, _redirects, 'utf-8'); - } else { - await fs.promises.writeFile(_redirectsURL, _redirects, 'utf-8'); - } + // Always use appendFile() because the redirects file could already exist, + // e.g. due to a `/public/_redirects` file that got copied to the output dir. + // If the file does not exist yet, appendFile() automatically creates it. + await fs.promises.appendFile(_redirectsURL, _redirects, 'utf-8'); }, }, }; |