1

I'd like to upload file to Firebase's Google Cloud Storage using Javascript. The problem is that I'm testing this on a local server, using npm run dev, and apparently this isn't allowing me to upload files to FB storage locations (that look like gs://xyz.appspot.com) because of cross-origin request blocking.

So, according to this recommendation, I'm now trying to set up an http server using Node's http-server module. My project is generated by Webpack and the output file is located in dist. Within dist I run http-server index.html and I see:

Starting up http-server, serving index.html
Available on:
  http://127.0.0.1:8080
  http://192.XXX:8080
Hit CTRL-C to stop the server
[Fri May 05 2017 08:23:37 GMT+0200 (CEST)] "GET /__webpack_hmr" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) xAppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"
[Fri May 05 2017 08:23:37 GMT+0200 (CEST)] "GET /__webpack_hmr" Error (404): "Not found"

And these last two messages keep repeating.

I go to the localhost address and there is no page found (404 error). Any ideas what is going wrong with my node server?

EDIT:

Actually, http-server takes the path of the file to be served, so I should have been using:

http-server ./

Here's the webpack config:

var path = require('path')

module.exports = {
  build: {
    env: require('./prod.env'),
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    productionSourceMap: true,
    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,
    productionGzipExtensions: ['js', 'css'],
    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  },
  dev: {
    env: require('./dev.env'),
    port: 8080,
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {},
    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: false
  }
}

This still doesn't solve my problem. The page loads, but I get the same cross-origin error.

Community
  • 1
  • 1
David J.
  • 1,753
  • 13
  • 47
  • 96
  • Seeing the webpack and server config would be very helpful – hansn May 05 '17 at 07:58
  • @hansn Added the webpack config (not sure what you mean by server config but I'll add whatever else you need if that's not enough) – David J. May 05 '17 at 08:15

0 Answers0