fix: Attachments on public share links broken when using AWS Accelerate
fix: Attachments broken when using non-collab and AWS bucket on the same host (https://github.com/outline/outline/discussions/3274\)
This commit is contained in:
@@ -6,6 +6,7 @@ export default function present(env: Record<string, any>): PublicEnv {
|
||||
return {
|
||||
URL: env.URL.replace(/\/$/, ""),
|
||||
AWS_S3_UPLOAD_BUCKET_URL: env.AWS_S3_UPLOAD_BUCKET_URL,
|
||||
AWS_S3_ACCELERATE_URL: env.AWS_S3_ACCELERATE_URL,
|
||||
CDN_URL: (env.CDN_URL || "").replace(/\/$/, ""),
|
||||
COLLABORATION_URL: (env.COLLABORATION_URL || env.URL)
|
||||
.replace(/\/$/, "")
|
||||
|
||||
@@ -21,8 +21,12 @@ function isLinkClose(token: Token) {
|
||||
function isAttachment(token: Token) {
|
||||
const href = token.attrGet("href");
|
||||
return (
|
||||
href?.includes("attachments.redirect") ||
|
||||
href?.startsWith(env.AWS_S3_UPLOAD_BUCKET_URL)
|
||||
// internal
|
||||
href?.startsWith("/api/attachments.redirect") ||
|
||||
// external (public share are pre-signed and this is a reasonable way of detecting them)
|
||||
((href?.startsWith(env.AWS_S3_UPLOAD_BUCKET_URL) ||
|
||||
href?.startsWith(env.AWS_S3_ACCELERATE_URL)) &&
|
||||
href?.includes("X-Amz-Signature"))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ export type PublicEnv = {
|
||||
CDN_URL: string;
|
||||
COLLABORATION_URL: string;
|
||||
AWS_S3_UPLOAD_BUCKET_URL: string;
|
||||
AWS_S3_ACCELERATE_URL: string;
|
||||
DEPLOYMENT: "hosted" | "";
|
||||
ENVIRONMENT: "production" | "development";
|
||||
SENTRY_DSN: string | undefined;
|
||||
|
||||
Reference in New Issue
Block a user