Skip to content

Commit

Permalink
Added Content-Type on html pages
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianFun123 committed Nov 5, 2023
1 parent 6cbc9d2 commit 3a5908b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions backend/src/main/java/de/interaapps/pastefy/Pastefy.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import de.interaapps.pastefy.model.database.Paste;
import de.interaapps.pastefy.model.database.User;
import de.interaapps.pastefy.model.responses.ExceptionResponse;
import org.eclipse.jetty.util.IO;
import org.javawebstack.httpserver.HTTPServer;
import org.javawebstack.httpserver.handler.RequestHandler;
import org.javawebstack.httpserver.handler.StaticFileHandler;
import org.javawebstack.orm.ORM;
import org.javawebstack.orm.ORMConfig;
import org.javawebstack.orm.Repo;
Expand Down Expand Up @@ -260,12 +262,15 @@ protected void setupServer() {
return false;
});


RequestHandler requestHandler = exchange -> {
try {
InputStream file = getClass().getClassLoader().getResourceAsStream("static/index.html");
if (file == null) {
throw new NotFoundException();
}

exchange.header("Content-Type", "text/html; charset=UTF-8");
exchange.write(file);
} catch (IOException e) {
e.printStackTrace();
Expand All @@ -279,6 +284,7 @@ protected void setupServer() {

httpServer.get("/", requestHandler);
httpServer.staticResourceDirectory("/", "static");

httpServer.get("/api/{*:path}", e -> {
throw new NotFoundException();
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/CreatePaste.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
</div>
</template>
<script>
import {CodeEditor} from 'petrel'
import { CodeEditor } from 'petrel'
import CryptoJS from "crypto-js";
import hljs from "highlight.js";
import LANGUAGE_REPLACEMENTS from '../assets/data/langReplacements'
Expand Down

0 comments on commit 3a5908b

Please sign in to comment.