Skip to content

Commit 5d63be2

Browse files
committed
Fixed class name and routing file paths
1 parent 9ae2b9a commit 5d63be2

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

backend/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

5-
<groupId>com.example</groupId>
5+
<groupId>com.codesignal</groupId>
66
<artifactId>pastebin</artifactId>
77
<version>0.0.1-SNAPSHOT</version>
88
<name>pastebin</name>

backend/src/main/java/com/codesignal/pastebin/controller/FrontendController.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,32 @@
1414
@RestController
1515
public class FrontendController {
1616
private File resolveIndexHtml() {
17+
// When running from repo root
1718
File local = new File("frontend/dist/index.html");
1819
if (local.exists()) return local;
20+
21+
// When running from backend directory
22+
File sibling = new File("../frontend/dist/index.html");
23+
if (sibling.exists()) return sibling;
24+
25+
// When running in Docker image
1926
File container = new File("/app/frontend/dist/index.html");
2027
if (container.exists()) return container;
2128
return null;
2229
}
2330
private File resolveStatic(String relPath) {
2431
if (relPath == null || relPath.isBlank()) return null;
2532
if (relPath.startsWith("/")) relPath = relPath.substring(1);
33+
34+
// When running from repo root
2635
File local = new File("frontend/dist/" + relPath);
2736
if (local.exists() && local.isFile()) return local;
37+
38+
// When running from backend directory
39+
File sibling = new File("../frontend/dist/" + relPath);
40+
if (sibling.exists() && sibling.isFile()) return sibling;
41+
42+
// When running in Docker image
2843
File container = new File("/app/frontend/dist/" + relPath);
2944
if (container.exists() && container.isFile()) return container;
3045
return null;

0 commit comments

Comments
 (0)