Use S3 and CloudFront for static files

This commit is contained in:
video-prize-ranch 2022-01-28 18:44:36 -05:00
parent be24ab2342
commit e3488c3527
No known key found for this signature in database
GPG Key ID: D8EAA4C5B12A7281
7 changed files with 17 additions and 17 deletions

View File

@ -8,7 +8,7 @@ import (
func FrontpageHandler(c *fiber.Ctx) error { func FrontpageHandler(c *fiber.Ctx) error {
utils.SetHeaders(c) utils.SetHeaders(c)
c.Set("Cache-Control", "public,max-age=31557600") c.Set("Cache-Control", "public,max-age=31557600")
c.Set("Content-Security-Policy", "default-src 'none'; style-src 'self'; img-src 'self'; font-src 'self'; block-all-mixed-content") c.Set("Content-Security-Policy", "default-src 'none'; style-src 'self' *.cloudfront.net; img-src 'self' *.cloudfront.net; font-src 'self'; block-all-mixed-content")
return c.Render("frontpage", fiber.Map{}) return c.Render("frontpage", fiber.Map{})
} }

View File

@ -9,7 +9,7 @@ import (
func HandleGallery(c *fiber.Ctx) error { func HandleGallery(c *fiber.Ctx) error {
utils.SetHeaders(c) utils.SetHeaders(c)
c.Set("Content-Security-Policy", "default-src 'none'; style-src 'self'; media-src 'self' *.cloudfront.net; img-src 'self' *.cloudfront.net; font-src 'self'; block-all-mixed-content") c.Set("Content-Security-Policy", "default-src 'none'; style-src 'self' *.cloudfront.net; media-src 'self' *.cloudfront.net; img-src 'self' *.cloudfront.net; font-src 'self' *.cloudfront.net; block-all-mixed-content")
album, err := api.FetchAlbum(c.Params("galleryID")) album, err := api.FetchAlbum(c.Params("galleryID"))
if err != nil { if err != nil {

View File

@ -12,7 +12,7 @@ import (
func HandleUser(c *fiber.Ctx) error { func HandleUser(c *fiber.Ctx) error {
utils.SetHeaders(c) utils.SetHeaders(c)
c.Set("Cache-Control", "public,max-age=604800") c.Set("Cache-Control", "public,max-age=604800")
c.Set("Content-Security-Policy", "default-src 'none'; style-src 'self' 'unsafe-inline'; media-src 'self' *.cloudfront.net; img-src 'self' *.cloudfront.net; font-src 'self'; block-all-mixed-content") c.Set("Content-Security-Policy", "default-src 'none'; style-src 'self' 'unsafe-inline' *.cloudfront.net; media-src 'self' *.cloudfront.net; img-src 'self' *.cloudfront.net; font-src 'self' *.cloudfront.net; block-all-mixed-content")
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
wg.Add(2) wg.Add(2)

View File

@ -6,7 +6,7 @@
{{> partials/head }} {{> partials/head }}
<link rel="stylesheet" href="/static/css/frontpage.css" /> <link rel="stylesheet" href="https://d12bxz4wjlvqjb.cloudfront.net/static/css/frontpage.css" />
</head> </head>

View File

@ -6,9 +6,9 @@
{{> partials/head }} {{> partials/head }}
<link rel="stylesheet" href="/static/fonts/Material-Icons-Outlined.css" /> <link rel="stylesheet" href="https://d12bxz4wjlvqjb.cloudfront.net/static/fonts/Material-Icons-Outlined.css" />
<link rel="stylesheet" href="/static/css/album.css" /> <link rel="stylesheet" href="https://d12bxz4wjlvqjb.cloudfront.net/static/css/album.css" />
<link rel="stylesheet" href="/static/css/comments.css" /> <link rel="stylesheet" href="https://d12bxz4wjlvqjb.cloudfront.net/static/css/comments.css" />
</head> </head>

View File

@ -2,15 +2,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="apple-touch-icon" sizes="180x180" href="/static/favicon/apple-touch-icon.png"> <link rel="apple-touch-icon" sizes="180x180" href="https://d12bxz4wjlvqjb.cloudfront.net/static/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/favicon/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="32x32" href="https://d12bxz4wjlvqjb.cloudfront.net/static/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/favicon/favicon-16x16.png"> <link rel="icon" type="image/png" sizes="16x16" href="https://d12bxz4wjlvqjb.cloudfront.net/static/favicon/favicon-16x16.png">
<link rel="manifest" href="/static/favicon/site.webmanifest"> <link rel="manifest" href="https://d12bxz4wjlvqjb.cloudfront.net/static/favicon/site.webmanifest">
<link rel="mask-icon" href="/static/favicon/safari-pinned-tab.svg" color="#1e88e5"> <link rel="mask-icon" href="https://d12bxz4wjlvqjb.cloudfront.net/static/favicon/safari-pinned-tab.svg" color="#1e88e5">
<link rel="shortcut icon" href="/static/favicon/favicon.ico"> <link rel="shortcut icon" href="https://d12bxz4wjlvqjb.cloudfront.net/static/favicon/favicon.ico">
<meta name="msapplication-TileColor" content="#603cba"> <meta name="msapplication-TileColor" content="#603cba">
<meta name="msapplication-config" content="/static/favicon/browserconfig.xml"> <meta name="msapplication-config" content="/static/favicon/browserconfig.xml">
<meta name="theme-color" content="#ffffff"> <meta name="theme-color" content="#ffffff">
<link rel="stylesheet" href="/static/fonts/Material-Icons-Outlined.css" /> <link rel="stylesheet" href="https://d12bxz4wjlvqjb.cloudfront.net/static/fonts/Material-Icons-Outlined.css" />
<link rel="stylesheet" href="/static/css/base.css"/> <link rel="stylesheet" href="https://d12bxz4wjlvqjb.cloudfront.net/static/css/base.css"/>

View File

@ -6,8 +6,8 @@
{{> partials/head }} {{> partials/head }}
<link rel="stylesheet" href="/static/fonts/Material-Icons-Outlined.css" /> <link rel="stylesheet" href="https://d12bxz4wjlvqjb.cloudfront.net/static/fonts/Material-Icons-Outlined.css" />
<link rel="stylesheet" href="/static/css/user.css" /> <link rel="stylesheet" href="https://d12bxz4wjlvqjb.cloudfront.net/static/css/user.css" />
</head> </head>