aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2022-06-09 15:39:43 +0000
committerterminaldweller <thabogre@gmail.com>2022-06-09 15:39:43 +0000
commit2f7516a0af0eaca205b71415a0910084cb452d33 (patch)
tree1c56cdbf77e826d142e5b2ea8ccf03273054de4f
parentserver link (diff)
downloadmdrtl-2f7516a0af0eaca205b71415a0910084cb452d33.tar.gz
mdrtl-2f7516a0af0eaca205b71415a0910084cb452d33.zip
wip
-rw-r--r--spring-front/src/components/Editor.js8
-rw-r--r--spring-front/src/config.js3
-rw-r--r--src/main/java/com/terminaldweller/doc/DocController.java2
-rw-r--r--src/main/java/com/terminaldweller/main/DevConfiguration.java6
-rwxr-xr-xtests.sh4
5 files changed, 13 insertions, 10 deletions
diff --git a/spring-front/src/components/Editor.js b/spring-front/src/components/Editor.js
index b77be1e..108d87d 100644
--- a/spring-front/src/components/Editor.js
+++ b/spring-front/src/components/Editor.js
@@ -134,7 +134,7 @@ export default class Editor extends React.Component {
// DELETE
handleDelete() {
- fetch(mdrtlConfig.serverURL + this.docId, {
+ fetch(`${mdrtlConfig.serverURL}/${this.docId}`, {
method: "DELETE",
headers: {
Accept: "application/json",
@@ -149,7 +149,7 @@ export default class Editor extends React.Component {
// GET
handleLoad(event) {
let res;
- fetch(mdrtlConfig.serverURL + this.docId).then((response) => {
+ fetch(`${mdrtlConfig.serverURL}/${this.docId}`).then((response) => {
if (!response.ok) {
throw new Error(`request failed with status ${response.status}`);
}
@@ -173,7 +173,7 @@ export default class Editor extends React.Component {
lastModified: Math.floor(Date.now() / 1000),
body: this.state.value,
};
- let response = await fetch(mdrtlConfig.serverURL + this.docId, {
+ let response = await fetch(`${mdrtlConfig.serverURL}/${this.docId}`, {
method: "POST",
body: JSON.stringify(obj),
mode: "cors",
@@ -190,7 +190,7 @@ export default class Editor extends React.Component {
lastModified: Math.floor(Date.now() / 1000),
body: this.state.value,
};
- let response = await fetch(mdrtlConfig.serverURL + this.docId, {
+ let response = await fetch(`${mdrtlConfig.serverURL}/${this.docId}`, {
method: "PUT",
body: JSON.stringify(obj),
mode: "cors",
diff --git a/spring-front/src/config.js b/spring-front/src/config.js
index e74952d..b85e2d1 100644
--- a/spring-front/src/config.js
+++ b/spring-front/src/config.js
@@ -1,3 +1,4 @@
export const mdrtlConfig = {
- serverURL: "editorsave.terminaldweller.com/api/v1/doc/",
+ // serverURL: "https://localhost:9080/api/v1/doc",
+ serverURL: "https://editorsave.terminaldweller.com/api/v1/doc",
};
diff --git a/src/main/java/com/terminaldweller/doc/DocController.java b/src/main/java/com/terminaldweller/doc/DocController.java
index 80e63a8..f45ba52 100644
--- a/src/main/java/com/terminaldweller/doc/DocController.java
+++ b/src/main/java/com/terminaldweller/doc/DocController.java
@@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
/** The document controller class. */
@RestController
-@CrossOrigin(origins = "https://localhost:7080")
+@CrossOrigin(origins = "https://localhost:7080, https://editor.terminaldweller.com")
@RequestMapping(path = "api/v1/doc")
public class DocController {
private final DocService docService;
diff --git a/src/main/java/com/terminaldweller/main/DevConfiguration.java b/src/main/java/com/terminaldweller/main/DevConfiguration.java
index 461e7bf..6f0137b 100644
--- a/src/main/java/com/terminaldweller/main/DevConfiguration.java
+++ b/src/main/java/com/terminaldweller/main/DevConfiguration.java
@@ -3,9 +3,11 @@ package com.terminaldweller;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
+// import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
+// @EnableWebMvc
@Profile("development")
public class DevConfiguration implements WebMvcConfigurer {
@@ -13,7 +15,7 @@ public class DevConfiguration implements WebMvcConfigurer {
public void addCorsMappings(CorsRegistry registry) {
registry
.addMapping("/**")
- .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
- .allowedOrigins("https://localhost:7080, https://editor.terminaldweller.com");
+ .allowedOrigins("https://localhost:7080, https://editor.terminaldweller.com")
+ .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS");
}
}
diff --git a/tests.sh b/tests.sh
index d23741f..3c18a44 100755
--- a/tests.sh
+++ b/tests.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-curl -k -X POST -H "Content-Type:application/json" -d '{"name":"doc1", "lastModified": 1652882691, "body":"Hello"}' "https://localhost:9080/api/v1/doc"
-curl -k -X GET "https://localhost:9080/api/v1/doc/2"
+curl -k -X POST -H "Content-Type:application/json" -d '{"name":"doc1", "lastModified": 1652882691, "body":"Hello"}' "https://localhost:9080/api/v1/doc/1"
+curl -k -X GET "https://localhost:9080/api/v1/doc/1"
curl -k -X DELETE "https://localhost:9080/api/v1/doc/1"
curl -k -X PUT -H "Content-Type:application/json" -d '{"id": 1, "body": "Die before I do"}' "https://localhost:9080/api/v1/doc/1"