mirror of
https://github.com/imputnet/cobalt.git
synced 2024-12-29 11:06:10 +00:00
added cors and title + description meta tags
This commit is contained in:
parent
9081f790ff
commit
22f13cc86f
|
@ -1,6 +1,7 @@
|
||||||
import "dotenv/config"
|
import "dotenv/config"
|
||||||
|
|
||||||
import express from "express";
|
import express from "express";
|
||||||
|
import cors from "cors";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import rateLimit from "express-rate-limit";
|
import rateLimit from "express-rate-limit";
|
||||||
|
|
||||||
|
@ -16,6 +17,8 @@ import stream from "./modules/stream/stream.js";
|
||||||
const commitHash = currentCommit();
|
const commitHash = currentCommit();
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
app.disable('x-powered-by');
|
||||||
|
|
||||||
if (fs.existsSync('./.env') && fs.existsSync('./config.json')) {
|
if (fs.existsSync('./.env') && fs.existsSync('./config.json')) {
|
||||||
const apiLimiter = rateLimit({
|
const apiLimiter = rateLimit({
|
||||||
windowMs: 20 * 60 * 1000,
|
windowMs: 20 * 60 * 1000,
|
||||||
|
@ -36,12 +39,10 @@ if (fs.existsSync('./.env') && fs.existsSync('./config.json')) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.set('etag', 'strong');
|
|
||||||
app.use('/api/', apiLimiter);
|
app.use('/api/', apiLimiter);
|
||||||
app.use('/api/stream', apiLimiterStream);
|
app.use('/api/stream', apiLimiterStream);
|
||||||
app.use('/', express.static('files'));
|
app.use('/', express.static('files'));
|
||||||
|
|
||||||
// avoid the %% URIError
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
try {
|
try {
|
||||||
decodeURIComponent(req.path)
|
decodeURIComponent(req.path)
|
||||||
|
@ -52,7 +53,7 @@ if (fs.existsSync('./.env') && fs.existsSync('./config.json')) {
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/api/:type', async (req, res) => {
|
app.get('/api/:type', cors({ origin: process.env.selfURL, optionsSuccessStatus: 200 }), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
switch (req.params.type) {
|
switch (req.params.type) {
|
||||||
case 'json':
|
case 'json':
|
||||||
|
|
|
@ -32,6 +32,8 @@ export default function(obj) {
|
||||||
<meta property="og:title" content="${appName}" />
|
<meta property="og:title" content="${appName}" />
|
||||||
<meta property="og:description" content="${loc(obj.lang, 'desc', 'embed')}" />
|
<meta property="og:description" content="${loc(obj.lang, 'desc', 'embed')}" />
|
||||||
<meta property="og:image" content="${process.env.selfURL}icons/generic.png" />
|
<meta property="og:image" content="${process.env.selfURL}icons/generic.png" />
|
||||||
|
<meta name="title" content="${appName}" />
|
||||||
|
<meta name="description" content="${loc(obj.lang, 'desc', 'embed')}" />
|
||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta name="twitter:card" content="summary" />
|
<meta name="twitter:card" content="summary" />
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/wukko/cobalt-web#readme",
|
"homepage": "https://github.com/wukko/cobalt-web#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^16.0.1",
|
"dotenv": "^16.0.1",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"express-rate-limit": "^6.3.0",
|
"express-rate-limit": "^6.3.0",
|
||||||
|
|
|
@ -17,6 +17,6 @@
|
||||||
"liveVideo": "i can't download a live video. wait for stream to finish and try again.",
|
"liveVideo": "i can't download a live video. wait for stream to finish and try again.",
|
||||||
"nothingToDownload": "it seems like there's nothing to download. try another link!",
|
"nothingToDownload": "it seems like there's nothing to download. try another link!",
|
||||||
"cantConnectToAPI": "i couldn't connect to {s} api. seems like either {s} is down or server ip got blocked. try again later.",
|
"cantConnectToAPI": "i couldn't connect to {s} api. seems like either {s} is down or server ip got blocked. try again later.",
|
||||||
"noStreamID": "there's no such stream id. you can't fool me!",
|
"noStreamID": "there's no such stream id.",
|
||||||
"noType": "there's no such expected response type."
|
"noType": "there's no such expected response type."
|
||||||
}
|
}
|
Loading…
Reference in a new issue