gatsby-plugin-s3
gatsby-plugin-s3 copied to clipboard
problem with redirecting from root
Hi,
i'm using this guide to create routing in my project
so the code in my gatsby-node.js
looks like this:
const config = require("./gatsby-config");
exports.onCreatePage = async ({ page, actions: { createPage, deletePage, createRedirect } }) => {
const isDev = process.env.NODE_ENV === "development";
const originalPath = page.path;
// delete default page
// await deletePage(page);
// create one page for each locale
await Promise.all(
config.siteMetadata.supportedLanguages.map(async lang => {
const localizedPath = `/${lang}${originalPath}`;
// create a redirect based on the accept-language header
createRedirect({
fromPath: originalPath,
toPath: localizedPath,
Language: lang,
isPermanent: false,
redirectInBrowser: isDev,
statusCode: 301
});
await createPage({
...page,
path: localizedPath,
context: {
...page.context,
originalPath,
lang
}
});
})
);
// fallback redirect if the language is not supported or the
// Accept-Language header is missing
createRedirect({
fromPath: "/",
toPath: `/${config.siteMetadata.defaultLanguage}${page.path}`,
isPermanent: true,
redirectInBrowser: isDev,
statusCode: 301
});
};
the problem is that I want to redirect from /
-> /en
or /fr
but with missing index.html
in root directory i only got 403
error...
Is it possible to do this with this gatsby-plugin-s3
?
This should be possible, and it's covered by E2E tests both with object-based redirects and with rule-based redirects.
I'm not too sure why it's not working for you, and I don't have time to look into it right now, but it should be possible.