diff --git a/back/index.js b/back/index.js index ce76faa..e87d476 100644 --- a/back/index.js +++ b/back/index.js @@ -1,20 +1,16 @@ const express = require('express'); const util = require('./util'); -const network = require('./data/network.json'); const realtime = require('./data/realtime'); const app = express(); -const port = 3000; - -app.use(express.static('dist')); +const port = 4321; app.get('/courses', async (req, res) => { + res.header('Access-Control-Allow-Origin', '*'); const courses = await realtime.getCourses(); return res.json(courses); }); -app.get('/network', (req, res) => res.json(network)); - app.listen(port, () => console.log(`App listening on port ${port}`)); diff --git a/front/map.js b/front/map.js index 8afc792..7a55447 100644 --- a/front/map.js +++ b/front/map.js @@ -21,15 +21,13 @@ const color = require('color'); const mapboxToken = `pk.eyJ1IjoibWF0dGVvZGVsYWJyZSIsImEiOiJja2NxaTUyMmUwcmFhMn\ h0NmFsdzQ3emxqIn0.cyxF0h36emIMTk3cc4VqUw`; -const server = window.origin; +const network = require('../back/data/network.json'); -const fetchDataSources = async () => +const makeDataSources = async () => { const segmentsSource = new VectorSource(); const stopsSource = new VectorSource(); - const network = (await axios.get(`${server}/network`)).data; - segmentsSource.addFeatures( Object.values(network.lines).flatMap(({color, routes}) => routes.map(({segments}) => @@ -105,7 +103,7 @@ const createMap = async (target) => }); // Data overlay - const {segmentsSource, stopsSource} = await fetchDataSources(); + const {segmentsSource, stopsSource} = await makeDataSources(); const segmentsBorderLayer = new VectorLayer({ source: segmentsSource,