mirror of
https://github.com/imputnet/cobalt.git
synced 2024-12-28 18:46:09 +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 express from "express";
|
||||
import cors from "cors";
|
||||
import * as fs from "fs";
|
||||
import rateLimit from "express-rate-limit";
|
||||
|
||||
|
@ -16,6 +17,8 @@ import stream from "./modules/stream/stream.js";
|
|||
const commitHash = currentCommit();
|
||||
const app = express();
|
||||
|
||||
app.disable('x-powered-by');
|
||||
|
||||
if (fs.existsSync('./.env') && fs.existsSync('./config.json')) {
|
||||
const apiLimiter = rateLimit({
|
||||
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/stream', apiLimiterStream);
|
||||
app.use('/', express.static('files'));
|
||||
|
||||
// avoid the %% URIError
|
||||
app.use((req, res, next) => {
|
||||
try {
|
||||
decodeURIComponent(req.path)
|
||||
|
@ -52,7 +53,7 @@ if (fs.existsSync('./.env') && fs.existsSync('./config.json')) {
|
|||
next();
|
||||
});
|
||||
|
||||
app.get('/api/:type', async (req, res) => {
|
||||
app.get('/api/:type', cors({ origin: process.env.selfURL, optionsSuccessStatus: 200 }), async (req, res) => {
|
||||
try {
|
||||
switch (req.params.type) {
|
||||
case 'json':
|
||||
|
|
|
@ -32,6 +32,8 @@ export default function(obj) {
|
|||
<meta property="og:title" content="${appName}" />
|
||||
<meta property="og:description" content="${loc(obj.lang, 'desc', 'embed')}" />
|
||||
<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="twitter:card" content="summary" />
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/wukko/cobalt-web#readme",
|
||||
"dependencies": {
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.0.1",
|
||||
"express": "^4.17.1",
|
||||
"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.",
|
||||
"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.",
|
||||
"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."
|
||||
}
|
Loading…
Reference in a new issue