diff --git a/packages/generators/src/app/templates/app.test.tpl.ts b/packages/generators/src/app/templates/app.test.tpl.ts index e798bcab08..e3f54e2903 100644 --- a/packages/generators/src/app/templates/app.test.tpl.ts +++ b/packages/generators/src/app/templates/app.test.tpl.ts @@ -11,7 +11,7 @@ import type { Server } from 'http' import { app } from '../${lib}/app' const port = app.get('port') -const appUrl = \`http://\${app.get('host')}:\${port}\` +const appUrl = \`http://localhost:\${port}\` describe('Feathers application tests', () => { let server: Server diff --git a/packages/generators/src/app/templates/client.test.tpl.ts b/packages/generators/src/app/templates/client.test.tpl.ts index aae82ae08e..19e06a8035 100644 --- a/packages/generators/src/app/templates/client.test.tpl.ts +++ b/packages/generators/src/app/templates/client.test.tpl.ts @@ -11,7 +11,7 @@ import { createClient } from '../${lib}/client' import rest from '@feathersjs/rest-client' const port = app.get('port') -const appUrl = \`http://\${app.get('host')}:\${port}\` +const appUrl = \`http://localhost:\${port}\` describe('client tests', () => { const client = createClient(rest(appUrl).axios(axios)) diff --git a/packages/generators/src/app/templates/configuration.tpl.ts b/packages/generators/src/app/templates/configuration.tpl.tsS similarity index 89% rename from packages/generators/src/app/templates/configuration.tpl.ts rename to packages/generators/src/app/templates/configuration.tpl.tsS index cc2d61810e..38a72895c7 100644 --- a/packages/generators/src/app/templates/configuration.tpl.ts +++ b/packages/generators/src/app/templates/configuration.tpl.tsS @@ -15,10 +15,14 @@ const defaultConfig = ({}: AppGeneratorContext) => ({ const customEnvironment = { port: { - __name: 'PORT', + __name: 'FEATHERS_PORT', __format: 'number' }, - host: 'HOSTNAME', + host: 'FEATHERS_HOSTNAME', + origins: { + __name: 'FEATHERS_ORIGINS', + __format: 'json' + }, authentication: { secret: 'FEATHERS_SECRET' } @@ -41,9 +45,9 @@ export const configurationSchema = { required: [ 'host', 'port', 'public' ], properties: { ...defaultAppSettings, - host: { type: 'string' }, port: { type: 'number' }, - public: { type: 'string' } + public: { type: 'string' }, + origins: { type: 'array', items: { type: 'string' } } } } as const @@ -61,9 +65,9 @@ import { dataValidator } from './validators' export const configurationSchema = Type.Intersect([ defaultAppConfiguration, Type.Object({ - host: Type.String(), port: Type.Number(), - public: Type.String() + public: Type.String(), + origins: Type.Array(Type.String()) }) ]) diff --git a/packages/generators/src/app/templates/index.tpl.ts b/packages/generators/src/app/templates/index.tpl.ts index 986bbf68a4..0a999d81f3 100644 --- a/packages/generators/src/app/templates/index.tpl.ts +++ b/packages/generators/src/app/templates/index.tpl.ts @@ -6,14 +6,14 @@ const template = ({}: AppGeneratorContext) => /* ts */ `import { app } from './a import { logger } from './logger' const port = app.get('port') -const host = app.get('host') +const origin = app.get('origins')[0] process.on('unhandledRejection', (reason) => logger.error('Unhandled Rejection %O', reason) ) app.listen(port).then(() => { - logger.info(\`Feathers app listening on http://\${host}:\${port}\`) + logger.info(\`Feathers app listening on \${origin}\`) }) `