R
R
reivunxx2021-05-26 10:58:47
HTTP headers
reivunxx, 2021-05-26 10:58:47

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);
})


There is also routing, and passport is also used (maybe it's about it? ..)

Here is the content of .htaccess
Compiled according to their instructions
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


I understand it like this:
When I try to go directly to the server address, I use http and get http; when the browser itself tries to load static files via http, it will redirect it to https. I assume that these two ways of accessing the server have different request headers, and one of them causes a redirect.

I wrote to support, but they said that they didn’t know why this was so, and that I should contact specialized resources for help

. This was not observed during local development, all links refer to http and receive data via http.
This is my first experience, so maybe I'm missing some fundamental thing that immediately catches your eye.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
reivunxx, 2021-05-31
@reivunxx

Everything was solved by disabling Helmet

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question