import React from 'react'
import createContentfulAdapter from 'tux-adapter-contentful'
import tux from './middleware/tux'
import history from 'react-chain-history'
import createReactChain from 'react-chain'
import Home from './home'

import './index.css'

const publicUrl = process.env.PUBLIC_URL ? process.env.PUBLIC_URL :
  process.env.SERVER ? 'https://localhost:3000' :
    `${location.protocol}//${location.host}/`

// Get your Contentful clientId (application Uid) from https://app.contentful.com/account/profile/developers/applications
const adapter = createContentfulAdapter({
  space: process.env.TUX_CONTENTFUL_SPACE_ID,
  accessToken: process.env.TUX_CONTENTFUL_ACCESS_TOKEN,
  clientId: process.env.TUX_CONTENTFUL_CLIENT_ID,
  redirectUri: publicUrl,
})

export default createReactChain()
  .chain(history())
  .chain(tux({ adapter }))
  .chain(() => () => <Home />)

import React from 'react'
import createContentfulAdapter from 'tux-adapter-contentful'
import tux from './middleware/tux'
import history from 'react-chain-history'
import createReactChain from 'react-chain'
import Home from './home'

import './index.css'

const publicUrl = process.env.PUBLIC_URL ? process.env.PUBLIC_URL :
  process.env.SERVER ? `https://localhost:${process.env.PORT || '5000'}` :
    `${location.protocol}//${location.host}/`

// Get your Contentful clientId (application Uid) from https://app.contentful.com/account/profile/developers/applications
const adapter = createContentfulAdapter({
  space: process.env.TUX_CONTENTFUL_SPACE_ID,
  accessToken: process.env.TUX_CONTENTFUL_ACCESS_TOKEN,
  clientId: process.env.TUX_CONTENTFUL_CLIENT_ID,
  redirectUri: publicUrl,
})

export default createReactChain()
  .chain(history())
  .chain(tux({ adapter }))
  .chain(() => () => <Home />)

Use PORT env var with 5000 fallback
Use PORT env var with 5000 fallback

Makes more sense IMO since the example site uses PORT=3000 but not this generated website, and 5000 seems to be the default of `tux-scripts start`. This approach solves both issues really, since it allows the user to set their own port, or just use the default.