Coder Social home page Coder Social logo

Comments (6)

lucasmotta avatar lucasmotta commented on May 18, 2024

Mainly because of this piece of code on the devServer.js file:

app.get('*', function(req, res) {
  res.sendFile(path.join(__dirname, 'index.html'));
});

That means that all your files (get('*')) will render the index.html no matter what. To fix that you can serve the static files before:

app.use(express.static('public'));

You can read more about here, but if still doesn't work, let me know.

from react-transform-boilerplate.

gaearon avatar gaearon commented on May 18, 2024

This is just Express and Webpack.
This boilerplate is meant to demonstrate React Transform and Webpack Hot Middleware.
It is not meant to implement every feature a project might need.

https://github.com/gaearon/react-transform-boilerplate#i-cant-serve-images--use-different-html-file--etc

from react-transform-boilerplate.

ngerritsen avatar ngerritsen commented on May 18, 2024

@lucasmotta That solution doesn't actually work because the get(*) overrides the calls

from react-transform-boilerplate.

vincent-dm avatar vincent-dm commented on May 18, 2024

Yes, that is also what confused me, since I'm not familiar with Express and wanted to build a small demo on top of this example. Changing the code to app.get('/', (req, res) => {... in combination with the code from @lucasmotta did the trick.

from react-transform-boilerplate.

lucasmotta avatar lucasmotta commented on May 18, 2024

@ngerritsen if you serve the static files before, it should work and the * middleware won't be even executed. Express executes the middleware in the order your add them.

from react-transform-boilerplate.

gaearon avatar gaearon commented on May 18, 2024

I'm happy to accept a PR making this behave more intuitively.

from react-transform-boilerplate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.