ember-fastboot / fastboot-app-server

A production-ready app server for running Ember FastBoot apps
140 stars 72 forks source link

Error downloading app: Unexpected token p in JSON at position 0 #86

Closed ehubbell closed 6 years ago

ehubbell commented 6 years ago

I've tested just about every scenario I can think trying to get a fastboot server up and running on an Elastic Beanstalk with S3. Disclaimer: this is my first go at setting up EB though. Either way, Fastboot's working fine in my local and I'd like to get it up on AWS so we can start configuring for the web. Here's our current setup:

DEPLOY Ember-cli-deploy Ember-cli-deploy-display-revision Ember-cli-deploy-fastboot-app-server Ember-cli-deploy-fastboot-app-server-aws

This gets our ember app built and deployed to S3 with both a fastboot-deploy-info.json file and a dist.zip file that I believe this project (fasstboot-app-server) is supposed to interpret and run.

Elastic Beanstalk I have two instances setup here. One uses what appears to be original library by @tomdale (fastboot-aws) and the other uses this library (fastboot-app-server). Thus far, I've cloned both projects, opened them, run npm install, added a dotenv dependency and added our S3 bucket / s3_key according to the instructions. Here's a look at the server.js file for each:

require('dotenv').config()

const S3_BUCKET = process.env.FASTBOOT_S3_BUCKET;
const S3_KEY = process.env.FASTBOOT_S3_KEY;

const S3Downloader = require('fastboot-s3-downloader');
const S3Notifier = require('fastboot-s3-notifier');
const FastBootAppServer = require('fastboot-app-server');

const MY_GLOBAL = 'MY GLOBAL';

let downloader = new S3Downloader({
  bucket: S3_BUCKET,
  key: S3_KEY
});

let notifier = new S3Notifier({
  bucket: S3_BUCKET,
  key: S3_KEY
});

let server = new FastBootAppServer({
  gzip: true,
  downloader: downloader,
  notifier: notifier
});

server.start();

When I try run the server file on my machine, I get the following error as it attempts to download the dist file from our S3 bucket:

SyntaxError: Unexpected token P in JSON at position 0

When I upload the directory to EB using eb create or eb deploy following the prompts, everything appears to work, however I get the same when I visit our EB on the web as well (see http://fastboot-staging.k6s5zcb2ru.us-east-1.elasticbeanstalk.com/).

I know fastboot is under active development and there are a few loose ends but I'd really appreciate if someone can steer me in the right direction here. Feels like there are a couple gaps in the readmen and would be happy to submit a PR documenting the steps I took get this setup and running.

ehubbell commented 6 years ago

Like a noob - I was pointing my S3_KEY mentioned above at the actual .zip file on my S3 bucket when, instead, it should be pointing at the fastboot-deploy-info.json file.

Also when testing locally, you should run npm install from your dist directory to avoid conflicts with modules (e.g. cannot find module 'moment')