logo
down
shadow

Express Static files on server not loading correctly but React Front end is loading correctly?


Express Static files on server not loading correctly but React Front end is loading correctly?

Content Index :

Express Static files on server not loading correctly but React Front end is loading correctly?
Tag : node.js , By : MK.
Date : November 29 2020, 04:01 AM

this one helps. Your react code is not showing up because index.html is not including it. Is public/bundle.js your transpiled react code? If so, add the following line to index.html, right after
:
<script src="/public/bundle.js"></script>
<script src="http://localhost:3312/bundle.js"></script>
module.exports = {
    devServer: {
        contentBase: path.join(__dirname, "/public"),
        historyApiFallback: true,
        port: 3000,
        proxy: {
            "/api": "http://localhost:5000"
        }
    },
    entry: ["babel-polyfill", __dirname + "/src/index.js"],
    output: {
        path: path.join(__dirname, "/public"),
        filename: "bundle.js",
        publicPath: "http://localhost:3312/"
    },
    module: {
        rules: [
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                use: {
                    loader: "babel-loader",
                    query: {
                        presets: ["react", "env", "stage-0"]
                    }
                }
            },
            {
                test: /\.css$/,
                use: [
                    { loader: "style-loader" },
                    { loader: "css-loader" },
                    { loader: "sass-loader" }
                ]
            }
        ]
    },
    plugins: [
        new BrowserSyncPlugin({
            host: "localhost",
            port: 3312,
            files: [
                "./public/*.html",
                "./public/assets/scss/*.scss",
                "./public/assets/variables/*.scss",
                "./public/assets/mixins/*.scss",
                "./public/assets/reset/*.scss"
            ],
            proxy: "http://localhost:3000/"
        })
    ]
};
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta name="theme-color" content="#000000" />
        <link
            href="/assets/css/styles.css"
            rel="stylesheet"
            type="text/css"
        />
        <title>Site</title>
    </head>
    <body>
        <div id="root"></div>
        <script src="http://localhost:3312/bundle.js"></script>
    </body>
</html>

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

django+nginx deployment not loading static files correctly


Tag : python , By : Gilmar Souza Jr.
Date : March 29 2020, 07:55 AM
To fix the issue you can do , Use this,
location /static_root/ { root /home/ubuntu/studykarma/django-react-redux-base/src/static_r‌​oot/; }

Express not serving static files correctly for react build


Tag : node.js , By : kgw
Date : March 29 2020, 07:55 AM
it fixes the issue What was posted here was close to the answer. Thank you for your help everyone! My real problem was that I had forgotten about the .htaccess file. See: https://github.com/facebook/create-react-app/issues/1171 and https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment

react router relative path to static files not loading correctly


Tag : javascript , By : quasarkitten
Date : March 29 2020, 07:55 AM
I wish did fix the issue. When you specify a proxy_pass directive then if you append anything to the end of the base URL Nginx will replace the portion of the original client request URL which matches your location block with whatever you have added to the proxy_pass URL.
So in your case you have location /auth and then proxy_pass http://authentication.internal.app/ with an all important trailing slash

How to correctly do a loading screen using react redux


Tag : javascript , By : simonth
Date : March 29 2020, 07:55 AM
this one helps. You can do that thing without using the redux its not necessary to use. If u call any Http API request or using the setTimeout.
import ReactDOM from "react-dom";
import React, { Component } from "react";

import "./styles.css";

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      isLoading: true
    };
  }

  componentDidMount() {
    fetch("https://jsonplaceholder.typicode.com/todos")
      .then(response => {
        return response.json();
      })
      .then(response => {
        this.setState({ isLoading: false });
        console.log("response :", response);
      })
      .catch(error => {
        this.setState({ isLoading: false });
        console.log("error :", error);
      });

    //or using setTimeout
     setTimeout(
        function() {
         this.setState({ isLoading: false });
        }.bind(this),
       3000
     );
  }

  render() {
    let { isLoading } = this.state;
    return (
      <div>
        {isLoading ? (
          <div className="App">
            <h1>Loading...</h1>
          </div>
        ) : (
          <div className="App">
            <h1>Hello CodeSandbox</h1>
            <h2>Start editing to see some magic happen!</h2>
          </div>
        )}
      </div>
    );
  }
}

AWS static site endpoint not loading correctly


Tag : amazon-s3 , By : mlapida
Date : March 29 2020, 07:55 AM
this will help Everything is correct except S3 website endpoint (not the REST API) doesn't support HTTPS and many modern browsers tries for https because of HSTS policy and you'll see connection timeout.
To make it work on HTTPS, you can use CloudFront and set up using below link:
Related Posts Related QUESTIONS :
  • node.js - how to check/get ssl certificate expiry date
  • How to show base64 image in react?
  • Error while pushing to Heroku: Cannot find module 'node-linux-x64/package.json'
  • Adding title element to paperjs SVG (using node.js)
  • Wait for firestore queries to finish before return a cloud function response
  • How to upload files larger than 10mb via google cloud http functions. ? Any alternative options?
  • How to use the NODE_OPTIONS environment variable to set the max_old_space_size globally in Windows?
  • Is nodejs representing Reactor or Proactor design pattern?
  • How to reference generated Prisma schema in my schema.graphql file for a query that filters by id
  • Cant figure out what is wrong with my models
  • npm ERR! EPROTO: protocol error, symlink '../@babel/parser/bin/babel-parser.js' -> '/home/vagrant/code/proadco.test/n
  • express-session - the difference between session id and connect.sid?
  • How do you run this list of command that come from a book Eloquent Javascript Node.js
  • how to convert from import to require in nodejs
  • POST request returns undefined
  • How to read large json file in node js?
  • AWS Lambda function written in nodejs is not updating my DynamoDB
  • Best way to define a Map Object in GraphQL Schema?
  • bigchaindb-driver not found in node_modules?
  • Upgrading yarn in root directory do not upgrade Workspace dependencies
  • How can I redirect all clients to another page with socket.io?
  • How is `cluster` and `worker_threads` work in Node.js?
  • AWS Lambda - Not able to a access JS file bundled in Layer (Node.js)
  • How to connect AWS Bitnami Certified Kafka AMI with Elastic Beanstalk nodejs environment using kafka-node
  • Define Shortcut Keys by user (add or edit by user in web app)?
  • 'this' in regular function vs fat arrow function in ES6, illustrated with an example of Mongoose
  • Could not find the implementation for builder @angular-devkit/build-angular:dev-server on ng serve command
  • The engine "node" is incompatible with this module
  • fs.readDirSync can't find dir in typescript?
  • Difference between keepAliveTimeout and timeout?
  • Visual Studio Code: "'tslib' cannot be found" error in Angular project
  • Embedding twitter timeline does not render in angular 7
  • Secret environment variables in Cloudbuild (with out files), how?
  • more than one 2dsphere index, not sure which to run geoNear
  • Why only 50 instances working on AWS lambda?
  • VSCode debugging (F5) react app gives SyntaxError: Unexpected identifier
  • How to use sweetalert in nodejs?
  • ng update --all does say 'Repository is not clean' evendought git commit
  • I want to update user profile
  • Uncaught ReferenceError: __webpack_dev_server_client__ is not defined
  • Webpack not being recognized after updates
  • use firebase Storage with Admin sdk node.js
  • If I want my graphql endpoint to be something other than `/graphql`, how do I configure it with the `GraphqlModule`?
  • Node.js JWT token
  • Filtering the user data with the age max and age min while date of birth is present in schema
  • What is the right way of implementing a service in an Angular application?
  • Redis doesn't update when many requests at once
  • Passport + SAML with metadata.xml file
  • downgrade NPM version on mac
  • tar EPERM: operation not permitted, futime
  • Two Public subnets can not communicate with private ip
  • How to upload file to Group Drive (Shared Drive) with Google Drive API V3?
  • Why is Firestore returning inconsistent results when queried inside Cloud Functions?
  • How to make post request with data in test-cafe?
  • React app not working in Internet Explorer 11
  • Node.js how to use socket.io in express route
  • What incorrect Metadata-Flavor header at GoogleAuth means?
  • Insert if not exists, if exists update
  • SyntaxError: await is only valid in async function with argon2
  • storing PDF files in mongoose using Node.js and Angular 6
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com