Ask coding questions

← Back to all posts
Issue with my website
maxina (61)

So in my website, I have a folder with an html file and a js file. For some reason, when I run it, and go to the website, it take my html code and puts it in the js code for some reason.

Any idea of why this would happen?

Answered by Coder100 (18192) [earned 5 cycles]
View Answer
Coder100 (18192)

please send the repl

maxina (61)

in the games folder i have an index.html file and js file when you run the code and go in inspect element in sources, youll see it puts the html code in the js file and gives and error

Coder100 (18192)


here is why

you never handled the case when it was games/main.js and always served the index.html by default.

Try using express.static like this:

app.use("/games", express.static(__dirname + "/games"));
maxina (61)

@Coder100 do i just replace that with the app.get code that i have?

Coder100 (18192)

you could make it all inside that one folder, but yes @maxina

maxina (61)

@Coder100 oh ok i got it now it works


and thanks a lot for thanking me im a newby to web development lol

Coder100 (18192)

mark as correct answer? @maxina