2

I'm using Ovh as my hosting provider and decide to move from it's default framework in php to node.js for my website http://www.clean-weather.com

I created an server.js file with node.js server code to manage the workflow and everything is working ok until the user refresh the page when it have a search query in its url ( it appears when you are searching for forecast in the chosen city ) for example: http://www.clean-weather.com/search?lat=51.50722&lng=-0.1275

const express = require('express');
const path = require('path');

const app = express();
const port = process.env.PORT || 3000;
const DIST_DIR = path.join(__dirname, 'src/build');
const HTML_FILE = path.join(DIST_DIR, 'index.html');

const mockResponse = {
  foo: 'bar',
  bar: 'foo'
};
app.use(express.static(DIST_DIR));
app.get('/api', (req, res) => {
  res.send(mockResponse);
});
app.get('/', (req, res) => {
  res.sendFile(HTML_FILE);
});

Now I'm stuck and trying to figure out what other code I should maybe insert in that will work for that particular scenario when there is a search query.

At the end I just want to mention that in the previous scenario without node this worked fine.

Thanks in advance for every advise and help.

mbojec
  • 163
  • 1
  • 7

0 Answers0