import feathers from '@feathersjs/feathers';
import rest from '@feathersjs/rest-client';
import socketio from '@feathersjs/socketio-client';
import authentication from '@feathersjs/authentication-client';
import io from 'socket.io-client';
import axios from 'axios';
import config from './config';

const storage = __SERVER__ ? null : require('localforage');

const host = clientUrl => (__SERVER__ ? `http://${config.apiHost}:${config.apiPort}` : clientUrl);

const configureApp = transport => feathers()
  .configure(transport)
  .configure(authentication({ storage }));

export const socket = io('', { path: host('/ws'), autoConnect: false });

export function createApp(req) {
  if (req === 'rest') {
    return configureApp(rest(host('/api')).axios(axios));
  }

  if (__SERVER__ && req) {
    const token = req.header('authorization') || (req.cookies && req.cookies['feathers-jwt']);
    const app = configureApp(
      rest(host('/api')).axios(
        axios.create({
          headers: {
            Cookie: req.get('cookie'),
            Authorization: token
          }
        })
      )
    );

    app.set('accessToken', token);

    return app;
  }

  return configureApp(socketio(socket));
}

@@ -791,103 +791,8 @@
 ) %7B%0A
-    const token = req.header('authorization') %7C%7C (req.cookies && req.cookies%5B'feathers-jwt'%5D);%0A
     
@@ -959,21 +959,43 @@
 zation: 
-token
+req.header('authorization')
 %0A       
@@ -1057,13 +1057,50 @@
 n', 
-token
+req.cookies && req.cookies%5B'feathers-jwt'%5D
 );%0A%0A

fix app.js