Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

365
Visualizações
static files are not loading for ejs (Node.js)

my static files are not loading for ejs. I get following error. I have tried in several ways to get loaded the statics but still I'm getting following errors

Refused to apply style from 'http://localhost:8080/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

info-order:63 GET http://localhost:8080/js/order.js net::ERR_ABORTED 404 (Not Found)

info-order:1 Refused to apply style from 'http://localhost:8080/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

my config file has following code..

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

/*config view engine*/

let configViewEngine = (app) => {
  app.use(express.static(path.join(__dirname + "./src/public")));

  app.set("viewEngine", "ejs");
  app.set("views", "./src/views");
};
module.exports = configViewEngine;

And I have link the stylesheet as follow.

<link rel="stylesheet" href="/css/style.css" />

my script tag on ejs as foillow..

<script src="/js/order.js"></script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try this:

app.use(express.static(path.join(__dirname, 'src/public')));
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda