Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs
1

Issue with my website

maxina
maxina

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?

2 years ago

Voters

Comments

TopNew
1
Coder100
Coder100

please send the repl

2 years ago
1
maxina
maxina

@Coder100

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
https://replit.com/@maxina/chat-example#games/index.html

2 years ago
1
Coder100
Coder100

@maxina

image

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"));
2 years ago
1
maxina
maxina

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

2 years ago
1
Coder100
Coder100

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

@maxina

2 years ago
1
maxina
maxina

@Coder100
oh ok i got it now it works

thanks!

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

2 years ago
2
Coder100
Coder100

nice!
mark as correct answer?

@maxina

2 years ago
1
Load more