-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
gofiber/template
#307Labels
Description
Bug Description
I'm using csrf middleware with v2.49.2 is worked. But after upgrade to v2.50.0, Errors will occur when visit any page.
failed to render: [Error (where: checkForValidIdentifiers)] context-key 'fiber.csrf.handler' (value: '&{config:0x14001198a00 sessionManager:<nil> storageManager:0x14000842e80}') is not a valid identifier
If change csrf config HandlerContextKey="csrf"
, is worked. Because HandlerContextKey
is default value fiber.csrf.handle
, So the default value contains the .
character. .xx
is usually used in templates to access properties or methods.
How to Reproduce
Steps to reproduce the behavior:
- Set fiber.Config
PassLocalsToViews: true
- Use
django
html engine. - Use CSRF middleware
Expected Behavior
Can visit all pages.
Fiber Version
v2.50.0
Code Snippet (optional)
package main
import (
"log"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/csrf"
"github.com/gofiber/template/django/v3"
)
func main() {
engine := django.New("./views", ".html")
// Pass the engine to the Views
app := fiber.New(fiber.Config{
Views: engine,
PassLocalsToViews: true,
})
app.Use(csrf.New())
app.Get("/", func(c *fiber.Ctx) error {
// Render index
return c.Render("index", fiber.Map{
"Title": "Hello, World!",
})
})
log.Fatal(app.Listen(":3000"))
}
Checklist:
- I agree to follow Fiber's Code of Conduct.
- I have checked for existing issues that describe my problem prior to opening this one.
- I understand that improperly formatted bug reports may be closed without explanation.