Skip to content

Commit f4f72f2

Browse files
fix(frontend): replace hard-coded media endpoint with value provided in attribute
1 parent c1e3c5f commit f4f72f2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

helpers/frontend/views/frontend-form.njk

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
hint: "Richtext hint text",
7575
field: {
7676
attributes: {
77-
editor: true
77+
editor: true,
78+
"editor-endpoint": application.mediaEndpoint
7879
}
7980
}
8081
}) }}

packages/frontend/components/textarea/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ const getButtonSvg = (name) => {
3737
export const TextareaFieldComponent = class extends HTMLElement {
3838
connectedCallback() {
3939
this.editor = this.getAttribute("editor");
40+
4041
if (this.editor !== "") {
4142
return;
4243
}
4344

45+
this.editorEndpoint = this.getAttribute("editor-endpoint");
4446
this.editorId = this.getAttribute("editor-id");
4547
this.editorImageUpload = this.getAttribute("editor-image-upload");
4648
this.editorLocale = this.getAttribute("editor-locale");
@@ -91,6 +93,7 @@ export const TextareaFieldComponent = class extends HTMLElement {
9193
italic: "_",
9294
},
9395
element: this.$textarea,
96+
imageUploadEndpoint: this.editorEndpoint,
9497
imageUploadFunction: this.uploadFile,
9598
minHeight: "6rem",
9699
previewClass: ["editor-preview", "s-flow"],
@@ -150,7 +153,7 @@ export const TextareaFieldComponent = class extends HTMLElement {
150153
formData.append("file", file);
151154

152155
try {
153-
const endpointResponse = await fetch("http://localhost:3000/media", {
156+
const endpointResponse = await fetch(this.options.imageUploadEndpoint, {
154157
method: "POST",
155158
body: formData,
156159
});

0 commit comments

Comments
 (0)