Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

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
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


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



Hi,

Thank you for reaching out to us.

Can you try to set homepage property to "/"?

You can check the official CRA deployment doc.
https://create-react-app.dev/docs/deployment/

Regards,
Lauris Stepanovs,
Keenthemes Support Team


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(