Answer the question
In order to leave comments, you need to log in
Why does the server for static files (images, css, js) return ERR_CONNECTION_TIMED_OUT referring to https when an address with http is specified in the markup?
I have a project with an express.js server.
I'm trying to put it on a sprinthost hosting.
The Express server seems to start, because when you try to go to the hosting address, it eventually returns the markup,
but all static files like styles do not.
For each of them I catch the error " Failed to load resource: net::ERR_CONNECTION_TIMED_OUT "
Moreover, the address that issues the timeout contains https, although in the markup the request goes to http. The addresses to static files are specified relative to the domain, but when you try to hard-set them to the address of the domain with the protocol, the effect is the same.
Here is the app.js code that concerns server startup and static resources:
const app = express();
const port = 80;
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
app.use(helmet());
app.listen(port,function (){
console.log('Сервер запущен по адресу http://localhost:' + port);
})
SetEnv GHOST_NODE_VERSION_CHECK false
PassengerStartupFile ./bin/www
PassengerResolveSymlinksInDocumentRoot on
Require all granted
PassengerAppType node
PassengerAppRoot /home/a0544981/domains/gxp.ru/public_html
Options -MultiViews
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question