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

Express res.sendfile(bundle) just loads browser with plain JS source in the actual window #124

Open
myk5000 opened this issue Apr 8, 2017 · 0 comments

Comments

@myk5000
Copy link

myk5000 commented Apr 8, 2017

Been using this boilerplate for dev using react (its great) and I'm having trouble testing sudo production build.
I'm trying to deploy to heroku by adding express server code and a procfile. I do a webpack -p to create the dist folder with its contents (bundle.js, [hash].jpegs).
I then use then express code to provide a way to serve up my simple react app.

`app.use("/static", express.static(path.join(__dirname,'dist')));
//used for referencing images from the bundle.js in the dist folder

app.get('*', (req, res) => {
res.sendFile(path.resolve(path.join(__dirname,'dist'), "bundle.js"));
});`

The weird thing is that if the 'app.use' line for setting up static reference is commented out, the homepage is rendered in the browser without the images loading simply by returning the bundle.js file from the get request. However if I do leave the app.use line in the code.. the browser just shows raw JS source in the window and does not render the page at all.. This has got me pretty confused, any tips would would be great. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant