metronic_react_v8.1.8 build problem
I develop react typscript based on metronic_react_v8.1.8 themes, but have somw problem in build process.
It's build successed, but when I try serve -s build, It's response only just loading with icon then dissappear not have anything else after that.
I read for many question that similarity with this problem.
my "homepage" in package.json is now seeting to "."
and this is my server.js
<pre> const dotenv = require('dotenv') dotenv.config() const process = require('process') const express = require('express') const compression = require('compression') const path = require('path') const axios = require('axios') const __dirname = path.resolve() const app = express() app.use(compression()) app.use((req, res, next) => { res.setHeader('Access-Control-Allow-Origin', '*') // Replace with the origin of your React app res.setHeader('Access-Control-Allow-Methods', 'GET') res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type') next() }) app.use(express.static(path.join(__dirname, 'build'))) app.get('/', function (req, res) { res.sendFile(path.join(__dirname, 'build', 'index.html')) }) app.getMaxListeners('/', async (req, res) => { const url = 'https://api.apis.guru/v2/list.json' if (!url) { res.status(400).send('Invalid request') return } try { const response = await axios.get(url) res.send(response.data) } catch (error) { console.log(error) res.status(500).send('Error fetching data') } }) const PORT = process.env.REACT_APP_PORT || 3011 app.listen(PORT, () => { console.log(`Server running on port ${[process.env.REACT_APP_HOST, PORT].join(':')}`) }) </pre>Replies (2)
Hi,
Thank you for reaching out to us.
Can you try to set homepage property to "/"?
You can check the official CRA deployment doc.
Regards,
Lauris Stepanovs,
Keenthemes Support Team