Skip to content

Commit

Permalink
Make Netlify adapter actually append redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
hippotastic committed Apr 11, 2022
1 parent 732ea38 commit b4b99dd
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 b4b99dd

Please sign in to comment.