Make Netlify adapter actually append redirects (#3079)

This commit is contained in:
hippotastic 2022-04-11 21:30:47 +02:00 committed by GitHub
parent 771127ea29
commit 9f248b0563
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/netlify': patch
---
Make Netlify adapter actually append redirects

View file

@ -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');
},
},
};