Send Markdown preview data as form params (#347)

This commit is contained in:
Thomas Miceli 2024-10-14 14:43:12 +02:00 committed by GitHub
parent 12696d23b0
commit 3068588111
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -251,7 +251,7 @@ func NewServer(isDev bool, sessionsPath string) *Server {
g1.Use(csrfInit)
g1.GET("/", create, logged)
g1.POST("/", processCreate, logged)
g1.GET("/preview", preview, logged)
g1.POST("/preview", preview, logged)
g1.GET("/healthcheck", healthcheck)
g1.GET("/metrics", metrics)

View file

@ -71,11 +71,12 @@ document.addEventListener("DOMContentLoaded", () => {
cmeditor!.classList.remove("hidden-important");
return;
} else {
fetch(`${baseUrl}/preview?` + new URLSearchParams({
content: editor.state.doc.toString()
}), {
method: 'GET',
const formData = new FormData();
formData.append('content', editor.state.doc.toString());
fetch(`${baseUrl}/preview`, {
method: 'POST',
credentials: 'same-origin',
body: formData
}).then(r => r.text()).then(r => {
let divpreview = dom.querySelector("div.preview") as HTMLElement;
divpreview!.innerHTML = r;