Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difference in behaviour locally vs AWS for server side relative redirects to public files #349

Open
thejuan opened this issue Feb 22, 2021 · 0 comments

Comments

@thejuan
Copy link
Contributor

thejuan commented Feb 22, 2021

Porting some logic from our older AWS Lambda@Edge, where we redirect requests for robots.txt to environment specific versions.

using FAB RC9

import { FABRuntime } from "@fab/core";
import { getEnvironment } from "@hatch-team/ui-config";

export default function robotsRedirect({ Router }: FABRuntime) {
  Router.on("/robots.txt", async ({ request }) => {
    const newUrl = `/robots.${getEnvironment().getName()}.txt`;
    console.log(`Redirecting robots.txt to ${newUrl}`);
    return new Request(newUrl, request.clone());
  });
}

This works perfectly when run locally with fab serve however on AWS we get FABs do not support relative urls other than /_assets

Changing the path to start with /_assets/ results in an empty 200 html response locally and Access Denied (assume is 404) on AWS

There is no physical robots.txt file but this doesn't seem to change the error when added.

The code seems to match the concepts in the docs around dog and cat origin request transformations.
I'll just make the code use an absolute URL for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant