Skip to content

Commit

Permalink
feat(client): customize netlify redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozwiaczek committed Oct 27, 2021
1 parent 5305e16 commit 16b39aa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ jest-test-results.json

**/e2e/screenshots
storybook-static

# Local Netlify folder
.netlify
6 changes: 2 additions & 4 deletions packages/client/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
publish = "build/"
command = "yarn build"

[[redirects]]
from = "/api/*"
to = "https://smart-gate-jj.herokuapp.com/:splat"
status = 200
[[plugins]]
package = "/plugins/netlify-plugin-customize-sg-redirects"

[[redirects]]
from = "/*"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
onPreBuild: ({ netlifyConfig }) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { redirects } = netlifyConfig;

const { REACT_APP_API_URL } = process.env;

redirects.push({
from: '/api/*',
to: `${REACT_APP_API_URL}/:splat`,
status: 200,
});
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: 'netlify-plugin-customize-sg-redirects'

0 comments on commit 16b39aa

Please sign in to comment.