Merge some standalone Vite entries into index.js (#37085)
Keep `swagger` and `external-render-helper` as a standalone entries for external render. - Move `devtest.ts` to `modules/` as init functions - Make external renders correctly load its helper JS and Gitea's current theme - Make external render iframe inherit Gitea's iframe's background color to avoid flicker - Add e2e tests for external render and OpenAPI iframe --------- Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -18,6 +18,8 @@ import (
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
"github.com/go-chi/cors"
|
||||
)
|
||||
|
||||
func CustomAssets() *assetfs.Layer {
|
||||
@@ -28,6 +30,15 @@ func AssetFS() *assetfs.LayeredFS {
|
||||
return assetfs.Layered(CustomAssets(), BuiltinAssets())
|
||||
}
|
||||
|
||||
func AssetsCors() func(next http.Handler) http.Handler {
|
||||
// static assets need to be served for external renders (sandboxed)
|
||||
return cors.Handler(cors.Options{
|
||||
AllowedOrigins: []string{"*"},
|
||||
AllowedMethods: []string{"HEAD", "GET"},
|
||||
MaxAge: 3600 * 24,
|
||||
})
|
||||
}
|
||||
|
||||
// FileHandlerFunc implements the static handler for serving files in "public" assets
|
||||
func FileHandlerFunc() http.HandlerFunc {
|
||||
assetFS := AssetFS()
|
||||
|
||||
Reference in New Issue
Block a user