ericmdantas / generator-ng-fullstack

Client, server or fullstack - it's up to you. ng-fullstack gives you the best of the latest.
MIT License
704 stars 103 forks source link

js and css files are served with text/html MIME type | npm run dev #216

Closed Karel-Kroeze closed 8 years ago

Karel-Kroeze commented 8 years ago

After a fresh yo ng-fullstack with the following settings;

{
  "generator-ng-fullstack": {
    "username": "Karel-Kroeze",
    "appName": "test",
    "stack": "fullstack",
    "server": "node",
    "client": "ng1",
    "transpilerServer": "node",
    "secure": false,
    "differentStaticServer": false
  }

and running the documented npm run dev, browser refuses to load the ToDo app, since MIME types don't match.

This is on a Ubuntu 14.04 box, it looks similar to #151, but that refers to deploying to heroku. I have yet to try a deployed dist build, so can't comment on that.

ericmdantas commented 8 years ago

Hey there, @Karel-Kroeze.

Just tried to reproduce it, but couldn't do it, but I'm on windows, so that could indicate something.

Couple questions:

"use strict";

const fs = require('fs');
const path = require('path');

module.exports = class StaticDispatcher {
    static sendIndex(req, res) {
      var _root = process.cwd();

      res.type('.html');

      fs.createReadStream(path.join(_root + '/client/dev/index.html'))
        .pipe(res);
    }
}

And then run npm run dev again.

Let me know how it goes.

ericmdantas commented 8 years ago

If that doesn't work, try using path.join in server/config/routes.config.js too:

// Before

       application.use(express.static(_root + _nodeModules));
       application.use(express.static(_root + _clientFiles));
// After

       application.use(express.static(path.join(_root, _nodeModules)));
       application.use(express.static(path.join(_root, _clientFiles)));
ericmdantas commented 8 years ago

Closing as there was no response.