Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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

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(':')}`)
})

Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

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



Even I was facing same issue . I just remove "homepage" in package.json


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(