diff --git a/apps/api/app/controllers/files_controller.rb b/apps/api/app/controllers/files_controller.rb index c6d04f6..8d557d7 100644 --- a/apps/api/app/controllers/files_controller.rb +++ b/apps/api/app/controllers/files_controller.rb @@ -7,8 +7,9 @@ class FilesController < ApplicationController full_path = BASE_PATH.join(requested) if File.directory?(full_path) - return redirect_to(request.path + "/", status: :moved_permanently) unless request.path.end_with?("/") - full_path = full_path.join('index.html') + index_path = full_path.join('index.html') + return head(:not_found) unless File.file?(index_path) + return redirect_to("/file/#{requested.chomp('/')}/index.html", status: :moved_permanently) end if File.file?(full_path)