I made a simple REST API that pulls data from MySQL. There is an SSL certificate in my site address.
https://example.com
When I go to the address, my site works.
When I want to access the REST API I created from my Site address, for example;
http://example.com:5007/survey_data
I can access with , but not with HTTPS
https://example.com:5007/survey_data
This address does not work.
const express = require('express');
const mysql = require('mysql2/promise');
const app = express();
const port = 5007;
const pool = mysql.createPool({
host: 'localhost',
user: 'admin',
password: 'admin1234',
database: 'test_database',
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0
});
app.get('/survey_data', async (req, res) => {
try {
const [rows] = await pool.query('SELECT * FROM survey_data');
res.json(rows);
} catch (err) {
console.error('Error ' + err);
res.status(500).json({ error: 'error' });
}
});
app.listen(port, () => {
console.log('Server working...');
});
There is an SSL certificate on my site address.
https://example.com
When I go to the address, my site works.