mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-21 19:19:31 -07:00
clean up paths for server and server-dist, remove cors #96
This commit is contained in:
16
index.mjs
16
index.mjs
@@ -1,9 +1,6 @@
|
||||
import 'dotenv/config';
|
||||
import express from 'express';
|
||||
import fs from 'fs';
|
||||
import corsPassThru from './cors/index.mjs';
|
||||
import radarPassThru from './cors/radar.mjs';
|
||||
import outlookPassThru from './cors/outlook.mjs';
|
||||
import playlist from './src/playlist.mjs';
|
||||
import OVERRIDES from './src/overrides.mjs';
|
||||
|
||||
@@ -13,12 +10,6 @@ const port = process.env.WS4KP_PORT ?? 8080;
|
||||
// template engine
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
// cors pass-thru to api.weather.gov
|
||||
app.get('/stations/*station', corsPassThru);
|
||||
app.get('/Conus/*radar', radarPassThru);
|
||||
app.get('/products/*product', outlookPassThru);
|
||||
app.get('/playlist.json', playlist);
|
||||
|
||||
// version
|
||||
const { version } = JSON.parse(fs.readFileSync('package.json'));
|
||||
|
||||
@@ -80,11 +71,6 @@ const geoip = (req, res) => {
|
||||
|
||||
// debugging
|
||||
if (process.env?.DIST === '1') {
|
||||
// distribution
|
||||
app.use('/images', express.static('./server/images'));
|
||||
app.use('/fonts', express.static('./server/fonts'));
|
||||
app.use('/scripts', express.static('./server/scripts'));
|
||||
app.use('/geoip', geoip);
|
||||
app.use('/', express.static('./dist'));
|
||||
} else {
|
||||
// debugging
|
||||
@@ -92,6 +78,8 @@ if (process.env?.DIST === '1') {
|
||||
app.use('/geoip', geoip);
|
||||
app.get('/', index);
|
||||
app.get('*name', express.static('./server'));
|
||||
// cors pass-thru to api.weather.gov
|
||||
app.get('/playlist.json', playlist);
|
||||
}
|
||||
|
||||
const server = app.listen(port, () => {
|
||||
|
||||
Reference in New Issue
Block a user