I´m making a server with express and he can´t find my static files

Viewed 27

I´m trying to configure the static files with express.... the html is ok, but he can´t find the CSS and JavaScript... I´m learning programming, so I can´t find the problem.... the problems showed in console : Refused to apply style from 'http://127.0.0.1/css/index.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

127.0.0.1/:16 GET http://127.0.0.1/images/ferramenta-de-simbolo-de-interface-de-calendario.svg 404 (Not Found)

127.0.0.1/:51 GET http://127.0.0.1/scripts/index.js net::ERR_ABORTED 404 (Not Found)

127.0.0.1/:20 GET http://127.0.0.1/images/engrenagem.svg 404 (Not Found)

127.0.0.1/:29 GET http://127.0.0.1/images/undraw_working_remotely_jh40.svg 404 (Not Found)

127.0.0.1/:38 GET http://127.0.0.1/images/undraw_best_place_r685.svg 404 (Not Found)

const express = require('express');
const path = require('path');

const server = express()

server.use(express.static('public'))

server
.get('/', (req, res) => {
     return res.sendFile(path.join(__dirname, "views", "index.html"))
});

server.get('/worksToDo', (req, res) => {
     return res.sendFile(path.join(__dirname, "views", "worksToDo.html"))
});



server.listen(80)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RememberMe</title>
    <link rel="stylesheet" href="/css/index.css">
    <link rel="icon" href="/images/icon.png">
    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Oswald:wght@700&display=swap" rel="stylesheet">
</head>
<body>
    <header >
        <div>
            <img src="images/ferramenta-de-simbolo-de-interface-de-calendario.svg" alt="">
            <h1>Re.</h1><h1>Me</h1>
        </div>
        <a href="./option.html">
            <img src="/images/engrenagem.svg" alt="">
        </a>
    </header>
    <main style="display: flex;  justify-content: space-between; align-items: center;" >
        <div class="cards" >
            <div class="card">
                <a href="/worksToDo">
                    <div class="cardWorksToDo">
                        <img src="/images/undraw_working_remotely_jh40.svg" alt="" >
                        <h5>Works to do </h5>
                    </div>
                </a>
             </div>
            <div class="card">
                <a href="/placesToVisit.html">
                    <div class="cardPlacesToVisit">
                        <img src="/images/undraw_best_place_r685.svg" alt="" width="200" >
                        <h5>Places to visit</h5>
                    </div>
                </a>
            </div>
        </div>
    <script src="/scripts/index.js"></script>
</body>
</html>

My directories

0 Answers
Related