diff --git a/backend/app/controllers/posts_controller.rb b/backend/app/controllers/posts_controller.rb index f46c48c..bbbce70 100644 --- a/backend/app/controllers/posts_controller.rb +++ b/backend/app/controllers/posts_controller.rb @@ -19,8 +19,16 @@ class PostsController < ApplicationController posts = posts.first(limit) end - render json: { posts: posts.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }), - next_cursor: } + render json: { posts: posts.map { |post| + post.as_json(include: { tags: { only: [:id, :name, :category, :post_count] } }).tap { |json| + json['thumbnail'] = + if post.thumbnail.attached? + rails_storage_proxy_url(post.thumbnail, only_path: false) + else + nil + end + } + }, next_cursor: } end def random diff --git a/frontend/public/.htaccess b/frontend/public/.htaccess index 133a5f4..51ba3ad 100644 --- a/frontend/public/.htaccess +++ b/frontend/public/.htaccess @@ -1,3 +1,9 @@ + + + Header set Cache-Control "max-age=31536000, public" + + + RewriteEngine On RewriteBase / diff --git a/frontend/src/pages/posts/PostListPage.tsx b/frontend/src/pages/posts/PostListPage.tsx index 626f18d..6d40409 100644 --- a/frontend/src/pages/posts/PostListPage.tsx +++ b/frontend/src/pages/posts/PostListPage.tsx @@ -101,6 +101,9 @@ export default () => { {post.title ))} )