Skip to content

Commit

Permalink
Make Netlify adapter actually append redirects (#3079)
Browse files Browse the repository at this point in the history
  • Loading branch information
hippotastic committed Apr 11, 2022
1 parent 771127e commit 9f248b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-elephants-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/netlify': patch
---

Make Netlify adapter actually append redirects
9 changes: 4 additions & 5 deletions packages/integrations/netlify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},
},
};
Expand Down

0 comments on commit 9f248b0

Please sign in to comment.