Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js and css files are not getting loaded in production environment. JS and CSS are again loading index.html #4369

Closed
atulsingh0913 opened this issue Apr 26, 2018 · 2 comments

Comments

@atulsingh0913
Copy link

Is this a bug report?

Yes, i think it is , but i am really not sure about this.

Did you try recovering your dependencies?

Yes

(Write your answer here.)

Which terms did you search for in User Guide?

Troubleshooting , Deployment

(Write your answer here if relevant.)

Environment

node-v:

  1. node -v: v8.9.4
  2. npm -v: 5.6.0
  3. yarn --version (if you use Yarn):
  4. npm ls react-scripts (if you haven’t ejected):

Then, specify:

  1. Operating system: Linux
  2. Browser and version (if relevant): All

Steps to Reproduce

(Write your steps here:)

  1. When i am hoisting application in local , things are working fine , but when i try to host the same in production environment , nothing is getting loaded . It is coming to index.html , but the js and css are not getting loaded.
  2. Production URL is -> https://stg.abc.com/tools/forecaster.
    Local URL -> http://localhost:8081/tools/forecaster

routes.js

import React from 'react'
import {
  BrowserRouter as Router,
  Route
} from 'react-router-dom';
import login from './components/login';

const myTool = () => (
  <Router>
    <div>
      <Route exact path="/tools/forecaster" component={login}/>

      <Route exact path="/tools/forecaster_hs" component={login}/>

    </div>
  </Router>
)
export default myTool

server.js

const express = require("express");
const app = express();
const path = require('path');
const port = process.env.PORT || 8081 ;

app.use(express.static(path.join(__dirname, 'build')));

app.get('/*', (req, res) => {
  res.sendFile(path.join(__dirname, 'public', 'index.html'));
});

app.listen(port);

Expected behaviour

The static assets should load from the build path

Actual behaviour

The static assets are also loading index.html file . It is not loading these files.

@miraage
Copy link

miraage commented Apr 27, 2018

Did you provide PUBLIC_URL or homepage in the package.json? docs.

@gaearon
Copy link
Contributor

gaearon commented May 3, 2018

Closing per lack of response

@gaearon gaearon closed this as completed May 3, 2018
@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants