fix(monorepo): make sure to use 127.0.0.1 instead of localhost

This commit is contained in:
Gergő Jedlicska
2023-08-03 10:28:57 +02:00
parent 10d9a6448f
commit ad0228c434
22 changed files with 82 additions and 32 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
schema: 'http://localhost:3000/graphql' schema: 'http://127.0.0.1:3000/graphql'
extensions: extensions:
languageService: languageService:
# Cause it's busted # Cause it's busted
+1 -1
View File
@@ -29,7 +29,7 @@ services:
start_period: 90s start_period: 90s
environment: environment:
# TODO: Change this to the URL of the speckle server, as accessed from the network # TODO: Change this to the URL of the speckle server, as accessed from the network
CANONICAL_URL: 'http://localhost' CANONICAL_URL: 'http://127.0.0.1'
# TODO: Change this to a unique secret for this server # TODO: Change this to a unique secret for this server
SESSION_SECRET: 'TODO:Replace' SESSION_SECRET: 'TODO:Replace'
+1 -1
View File
@@ -54,7 +54,7 @@ async function parseAndCreateCommit({
const userToken = process.env.USER_TOKEN const userToken = process.env.USER_TOKEN
const serverBaseUrl = process.env.SPECKLE_SERVER_URL || 'http://localhost:3000' const serverBaseUrl = process.env.SPECKLE_SERVER_URL || 'http://127.0.0.1:3000'
logger.info(`Creating commit for object (${id}), with message "${message}"`) logger.info(`Creating commit for object (${id}), with message "${message}"`)
const response = await fetch(serverBaseUrl + '/graphql', { const response = await fetch(serverBaseUrl + '/graphql', {
method: 'POST', method: 'POST',
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = require('knex')({
connection: { connection: {
application_name: 'speckle_fileimport_service', application_name: 'speckle_fileimport_service',
connectionString: connectionString:
process.env.PG_CONNECTION_STRING || 'postgres://speckle:speckle@localhost/speckle' process.env.PG_CONNECTION_STRING || 'postgres://speckle:speckle@127.0.0.1/speckle'
}, },
pool: { min: 0, max: 1 } pool: { min: 0, max: 1 }
// migrations are in managed in the server package // migrations are in managed in the server package
@@ -125,7 +125,7 @@ def import_obj():
# Commit # Commit
client = SpeckleClient( client = SpeckleClient(
host=os.getenv("SPECKLE_SERVER_URL", "localhost:3000"), use_ssl=False host=os.getenv("SPECKLE_SERVER_URL", "127.0.0.1:3000"), use_ssl=False
) )
client.authenticate_with_token(os.environ["USER_TOKEN"]) client.authenticate_with_token(os.environ["USER_TOKEN"])
+1 -1
View File
@@ -15,7 +15,7 @@
"node": "^18.17.0" "node": "^18.17.0"
}, },
"scripts": { "scripts": {
"dev": "cross-env POSTGRES_URL=postgres://speckle:speckle@localhost/speckle NODE_ENV=development LOG_PRETTY=true SPECKLE_SERVER_URL=http://localhost:3000 nodemon --no-experimental-fetch ./src/daemon.js", "dev": "cross-env POSTGRES_URL=postgres://speckle:speckle@127.0.0.1/speckle NODE_ENV=development LOG_PRETTY=true SPECKLE_SERVER_URL=http://127.0.0.1:3000 nodemon --no-experimental-fetch ./src/daemon.js",
"parse:ifc": "node --no-experimental-fetch ./ifc/import_file.js ./ifc/ifcs/steelplates.ifc 33763848d6 2e4bfb467a main File upload: steelplates.ifc", "parse:ifc": "node --no-experimental-fetch ./ifc/import_file.js ./ifc/ifcs/steelplates.ifc 33763848d6 2e4bfb467a main File upload: steelplates.ifc",
"lint": "eslint . --ext .js,.ts" "lint": "eslint . --ext .js,.ts"
}, },
@@ -35,7 +35,7 @@ def import_stl():
# Commit # Commit
client = SpeckleClient( client = SpeckleClient(
host=os.getenv("SPECKLE_SERVER_URL", "localhost:3000"), use_ssl=False host=os.getenv("SPECKLE_SERVER_URL", "127.0.0.1:3000"), use_ssl=False
) )
client.authenticate_with_token(os.environ["USER_TOKEN"]) client.authenticate_with_token(os.environ["USER_TOKEN"])
@@ -54,6 +54,37 @@ export type ActivityCollection = {
totalCount: Scalars['Int']; totalCount: Scalars['Int'];
}; };
export type AdminQueries = {
__typename?: 'AdminQueries';
projectList: ProjectCollection;
serverStatistics: ServerStatistics;
userList: AdminUserList;
};
export type AdminQueriesProjectListArgs = {
cursor?: InputMaybe<Scalars['String']>;
limit?: Scalars['Int'];
orderBy?: InputMaybe<Scalars['String']>;
query?: InputMaybe<Scalars['String']>;
visibility?: InputMaybe<Scalars['String']>;
};
export type AdminQueriesUserListArgs = {
cursor?: InputMaybe<Scalars['String']>;
limit?: Scalars['Int'];
query?: InputMaybe<Scalars['String']>;
role?: InputMaybe<ServerRole>;
};
export type AdminUserList = {
__typename?: 'AdminUserList';
cursor?: Maybe<Scalars['String']>;
items: Array<LimitedUser>;
totalCount: Scalars['Int'];
};
export type AdminUsersListCollection = { export type AdminUsersListCollection = {
__typename?: 'AdminUsersListCollection'; __typename?: 'AdminUsersListCollection';
items: Array<AdminUsersListItem>; items: Array<AdminUsersListItem>;
@@ -1581,11 +1612,16 @@ export type Query = {
_?: Maybe<Scalars['String']>; _?: Maybe<Scalars['String']>;
/** Gets the profile of the authenticated user or null if not authenticated */ /** Gets the profile of the authenticated user or null if not authenticated */
activeUser?: Maybe<User>; activeUser?: Maybe<User>;
/** All the streams of the server. Available to admins only. */ admin: AdminQueries;
/**
* All the streams of the server. Available to admins only.
* @deprecated use admin.projectList instead
*/
adminStreams?: Maybe<StreamCollection>; adminStreams?: Maybe<StreamCollection>;
/** /**
* Get all (or search for specific) users, registered or invited, from the server in a paginated view. * Get all (or search for specific) users, registered or invited, from the server in a paginated view.
* The query looks for matches in name, company and email. * The query looks for matches in name, company and email.
* @deprecated use admin.UserList instead
*/ */
adminUsers?: Maybe<AdminUsersListCollection>; adminUsers?: Maybe<AdminUsersListCollection>;
/** Gets a specific app from the server. */ /** Gets a specific app from the server. */
@@ -1615,6 +1651,7 @@ export type Query = {
*/ */
projectInvite?: Maybe<PendingStreamCollaborator>; projectInvite?: Maybe<PendingStreamCollaborator>;
serverInfo: ServerInfo; serverInfo: ServerInfo;
/** @deprecated use admin.serverStatistics instead */
serverStats: ServerStats; serverStats: ServerStats;
/** /**
* Returns a specific stream. Will throw an authorization error if active user isn't authorized * Returns a specific stream. Will throw an authorization error if active user isn't authorized
@@ -1834,6 +1871,7 @@ export type ServerInfo = {
canonicalUrl?: Maybe<Scalars['String']>; canonicalUrl?: Maybe<Scalars['String']>;
company?: Maybe<Scalars['String']>; company?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>; description?: Maybe<Scalars['String']>;
guestModeEnabled: Scalars['Boolean'];
inviteOnly?: Maybe<Scalars['Boolean']>; inviteOnly?: Maybe<Scalars['Boolean']>;
name: Scalars['String']; name: Scalars['String'];
roles: Array<Maybe<Role>>; roles: Array<Maybe<Role>>;
@@ -1846,6 +1884,7 @@ export type ServerInfoUpdateInput = {
adminContact?: InputMaybe<Scalars['String']>; adminContact?: InputMaybe<Scalars['String']>;
company?: InputMaybe<Scalars['String']>; company?: InputMaybe<Scalars['String']>;
description?: InputMaybe<Scalars['String']>; description?: InputMaybe<Scalars['String']>;
guestModeEnabled?: InputMaybe<Scalars['Boolean']>;
inviteOnly?: InputMaybe<Scalars['Boolean']>; inviteOnly?: InputMaybe<Scalars['Boolean']>;
name: Scalars['String']; name: Scalars['String'];
termsOfService?: InputMaybe<Scalars['String']>; termsOfService?: InputMaybe<Scalars['String']>;
@@ -1866,9 +1905,17 @@ export type ServerInviteCreateInput = {
export enum ServerRole { export enum ServerRole {
ServerAdmin = 'SERVER_ADMIN', ServerAdmin = 'SERVER_ADMIN',
ServerArchivedUser = 'SERVER_ARCHIVED_USER', ServerArchivedUser = 'SERVER_ARCHIVED_USER',
ServerGuest = 'SERVER_GUEST',
ServerUser = 'SERVER_USER' ServerUser = 'SERVER_USER'
} }
export type ServerStatistics = {
__typename?: 'ServerStatistics';
totalPendingInvites: Scalars['Int'];
totalProjectCount: Scalars['Int'];
totalUserCount: Scalars['Int'];
};
export type ServerStats = { export type ServerStats = {
__typename?: 'ServerStats'; __typename?: 'ServerStats';
/** An array of objects currently structured as { created_month: Date, count: int }. */ /** An array of objects currently structured as { created_month: Date, count: int }. */
+3 -3
View File
@@ -9,7 +9,7 @@
"request": "launch", "request": "launch",
"reAttach": true, "reAttach": true,
"name": "Launch localhost", "name": "Launch localhost",
"url": "http://localhost:3000", "url": "http://127.0.0.1:3000",
"webRoot": "${workspaceFolder}", "webRoot": "${workspaceFolder}",
"sourceMaps": true, "sourceMaps": true,
"trace": true, "trace": true,
@@ -21,10 +21,10 @@
] ]
}, },
{ {
"type": "pwa-chrome", "type": "chrome",
"request": "launch", "request": "launch",
"name": "Launch Chrome against localhost", "name": "Launch Chrome against localhost",
"url": "http://localhost:3000", "url": "http://127.0.0.1:3000",
"webRoot": "${workspaceFolder}", "webRoot": "${workspaceFolder}",
"sourceMaps": true, "sourceMaps": true,
"trace": true, "trace": true,
+1 -1
View File
@@ -1,7 +1,7 @@
module.exports = { module.exports = {
client: { client: {
service: 'speckle-server', service: 'speckle-server',
url: 'http://localhost:3000/graphql', url: 'http://127.0.0.1:3000/graphql',
includes: ['src/**/*.{js,jsx,ts,tsx,vue,gql}'] includes: ['src/**/*.{js,jsx,ts,tsx,vue,gql}']
} }
} }
+3 -3
View File
@@ -5,15 +5,15 @@ build:
run: run:
docker run -it --rm --net=host \ docker run -it --rm --net=host \
-e PG_CONNECTION_STRING="postgres://speckle:speckle@localhost/speckle" \ -e PG_CONNECTION_STRING="postgres://speckle:speckle@127.0.0.1/speckle" \
preview-service preview-service
run-release: run-release:
docker run -it --rm --net=host \ docker run -it --rm --net=host \
-e PG_CONNECTION_STRING="postgres://speckle:speckle@localhost/speckle" \ -e PG_CONNECTION_STRING="postgres://speckle:speckle@127.0.0.1/speckle" \
speckle/speckle-preview-service:v2.3.3 speckle/speckle-preview-service:v2.3.3
small: small:
docker build -t small-preview-service ../.. -f Dockerfile.small docker build -t small-preview-service ../.. -f Dockerfile.small
docker run -it --rm --net=host -e PG_CONNECTION_STRING="postgres://speckle:speckle@localhost/speckle" small-preview-service bash docker run -it --rm --net=host -e PG_CONNECTION_STRING="postgres://speckle:speckle@127.0.0.1/speckle" small-preview-service bash
+1 -1
View File
@@ -6,7 +6,7 @@ module.exports = require('knex')({
connection: { connection: {
application_name: 'speckle_preview_service', application_name: 'speckle_preview_service',
connectionString: connectionString:
process.env.PG_CONNECTION_STRING || 'postgres://speckle:speckle@localhost/speckle' process.env.PG_CONNECTION_STRING || 'postgres://speckle:speckle@127.0.0.1/speckle'
}, },
pool: { min: 0, max: 2 } pool: { min: 0, max: 2 }
// migrations are in managed in the server package // migrations are in managed in the server package
+1 -1
View File
@@ -24,7 +24,7 @@ After the viewer web page is up to date, run the preview service with:
yarn dev yarn dev
``` ```
This will use the default dev DB connection of `postgres://speckle:speckle@localhost/speckle`. You can pass the environment variable `PG_CONNECTION_STRING` to change this to a different DB. This will use the default dev DB connection of `postgres://speckle:speckle@127.0.0.1/speckle`. You can pass the environment variable `PG_CONNECTION_STRING` to change this to a different DB.
## Deployment notes ## Deployment notes
+2 -2
View File
@@ -35,7 +35,7 @@ ONBOARDING_STREAM_CACHE_BUST_NUMBER=1
# If you specify a user and password, do not specify the protocol in the # If you specify a user and password, do not specify the protocol in the
# POSTGRES_URL variable. # POSTGRES_URL variable.
# These defaults are set for the local development environment # These defaults are set for the local development environment
POSTGRES_URL="localhost" POSTGRES_URL="127.0.0.1"
# this overrides the default root user in the postgres instance # this overrides the default root user in the postgres instance
POSTGRES_USER="speckle" POSTGRES_USER="speckle"
# this sets the root user password in the postgres instance # this sets the root user password in the postgres instance
@@ -123,7 +123,7 @@ STRATEGY_LOCAL=true
# If your frontend is served in dev from somewhere else, # If your frontend is served in dev from somewhere else,
# this is going to help out :) # this is going to help out :)
############################################################ ############################################################
# FRONTEND_HOST=localhost # FRONTEND_HOST=127.0.0.1
# FRONTEND_PORT=8081 # FRONTEND_PORT=8081
SPECKLE_AUTOMATE_URL="http://127.0.0.1:3030" SPECKLE_AUTOMATE_URL="http://127.0.0.1:3030"
+2 -2
View File
@@ -355,7 +355,7 @@ export async function shutdown(): Promise<void> {
const shouldUseFrontendProxy = () => process.env.NODE_ENV === 'development' const shouldUseFrontendProxy = () => process.env.NODE_ENV === 'development'
async function createFrontendProxy() { async function createFrontendProxy() {
const frontendHost = process.env.FRONTEND_HOST || 'localhost' const frontendHost = process.env.FRONTEND_HOST || '127.0.0.1'
const frontendPort = process.env.FRONTEND_PORT || 8080 const frontendPort = process.env.FRONTEND_PORT || 8080
const { createProxyMiddleware } = await import('http-proxy-middleware') const { createProxyMiddleware } = await import('http-proxy-middleware')
@@ -388,7 +388,7 @@ export async function startHttp(
app.use(await createFrontendProxy()) app.use(await createFrontendProxy())
startupLogger.info('✨ Proxying frontend-1 (dev mode):') startupLogger.info('✨ Proxying frontend-1 (dev mode):')
startupLogger.info(`👉 main application: http://localhost:${port}/`) startupLogger.info(`👉 main application: http://127.0.0.1:${port}/`)
} }
// Production mode // Production mode
+2 -2
View File
@@ -84,14 +84,14 @@ const config = {
test: { test: {
...commonConfig, ...commonConfig,
connection: { connection: {
connectionString: connectionUri || 'postgres://localhost/speckle2_test', connectionString: connectionUri || 'postgres://127.0.0.1/speckle2_test',
application_name: 'speckle_server' application_name: 'speckle_server'
} }
}, },
development: { development: {
...commonConfig, ...commonConfig,
connection: { connection: {
connectionString: connectionUri || 'postgres://localhost/speckle2_dev', connectionString: connectionUri || 'postgres://127.0.0.1/speckle2_dev',
application_name: 'speckle_server' application_name: 'speckle_server'
} }
}, },
@@ -67,7 +67,7 @@ describe('Services @apps-services', () => {
name: 'test application', name: 'test application',
public: true, public: true,
scopes: [Scopes.Streams.Read], scopes: [Scopes.Streams.Read],
redirectUrl: 'http://localhost:1335' redirectUrl: 'http://127.0.0.1:1335'
}) })
expect(res).to.have.property('id') expect(res).to.have.property('id')
@@ -88,7 +88,7 @@ describe('Services @apps-services', () => {
}) })
it('Should fail to register an app with no scopes', async () => { it('Should fail to register an app with no scopes', async () => {
await createApp({ name: 'test application2', redirectUrl: 'http://localhost:1335' }) await createApp({ name: 'test application2', redirectUrl: 'http://127.0.0.1:1335' })
.then(() => { .then(() => {
throw new Error('this should have been rejected') throw new Error('this should have been rejected')
}) })
@@ -47,7 +47,7 @@ const command: CommandModule<unknown, { testQueueId: string }> = {
app.listen(PORT, () => { app.listen(PORT, () => {
cliLogger.info(`Running on ${PORT}...`) cliLogger.info(`Running on ${PORT}...`)
cliLogger.info( cliLogger.info(
`For the UI, open http://localhost:${PORT}/, and make sure Redis is running` `For the UI, open http://127.0.0.1:${PORT}/, and make sure Redis is running`
) )
}) })
@@ -12,7 +12,7 @@ module.exports = {
async getServerInfo() { async getServerInfo() {
const serverInfo = await Info().select('*').first() const serverInfo = await Info().select('*').first()
serverInfo.version = process.env.SPECKLE_SERVER_VERSION || 'dev' serverInfo.version = process.env.SPECKLE_SERVER_VERSION || 'dev'
serverInfo.canonicalUrl = process.env.CANONICAL_URL || 'localhost' serverInfo.canonicalUrl = process.env.CANONICAL_URL || '127.0.0.1'
return serverInfo return serverInfo
}, },
@@ -1874,6 +1874,7 @@ export type ServerInfo = {
canonicalUrl?: Maybe<Scalars['String']>; canonicalUrl?: Maybe<Scalars['String']>;
company?: Maybe<Scalars['String']>; company?: Maybe<Scalars['String']>;
description?: Maybe<Scalars['String']>; description?: Maybe<Scalars['String']>;
guestModeEnabled: Scalars['Boolean'];
inviteOnly?: Maybe<Scalars['Boolean']>; inviteOnly?: Maybe<Scalars['Boolean']>;
name: Scalars['String']; name: Scalars['String'];
roles: Array<Maybe<Role>>; roles: Array<Maybe<Role>>;
@@ -1886,6 +1887,7 @@ export type ServerInfoUpdateInput = {
adminContact?: InputMaybe<Scalars['String']>; adminContact?: InputMaybe<Scalars['String']>;
company?: InputMaybe<Scalars['String']>; company?: InputMaybe<Scalars['String']>;
description?: InputMaybe<Scalars['String']>; description?: InputMaybe<Scalars['String']>;
guestModeEnabled?: InputMaybe<Scalars['Boolean']>;
inviteOnly?: InputMaybe<Scalars['Boolean']>; inviteOnly?: InputMaybe<Scalars['Boolean']>;
name: Scalars['String']; name: Scalars['String'];
termsOfService?: InputMaybe<Scalars['String']>; termsOfService?: InputMaybe<Scalars['String']>;
@@ -1906,6 +1908,7 @@ export type ServerInviteCreateInput = {
export enum ServerRole { export enum ServerRole {
ServerAdmin = 'SERVER_ADMIN', ServerAdmin = 'SERVER_ADMIN',
ServerArchivedUser = 'SERVER_ARCHIVED_USER', ServerArchivedUser = 'SERVER_ARCHIVED_USER',
ServerGuest = 'SERVER_GUEST',
ServerUser = 'SERVER_USER' ServerUser = 'SERVER_USER'
} }
@@ -8,7 +8,7 @@ const createJsonEchoTransporter = () => createTransport({ jsonTransport: true })
const initSmtpTransporter = async () => { const initSmtpTransporter = async () => {
try { try {
const smtpTransporter = createTransport({ const smtpTransporter = createTransport({
host: process.env.EMAIL_HOST || 'localhost', host: process.env.EMAIL_HOST || '127.0.0.1',
port: parseInt(process.env.EMAIL_PORT || '587'), port: parseInt(process.env.EMAIL_PORT || '587'),
secure: process.env.EMAIL_SECURE === 'true', secure: process.env.EMAIL_SECURE === 'true',
auth: { auth: {
+4 -4
View File
@@ -32,7 +32,7 @@ After you have PostgreSQL and Redis running, in the `packages/server` folder:
- If you have a custom setup, open and edit the `.env` & `.env.test` files, filling in the required variables, - If you have a custom setup, open and edit the `.env` & `.env.test` files, filling in the required variables,
- run `yarn install`, - run `yarn install`,
- finally `yarn dev`, - finally `yarn dev`,
- check `localhost:3000/graphql` out! - check `127.0.0.1:3000/graphql` out!
## Developing ## Developing
@@ -72,18 +72,18 @@ Use `yarn cli bull monitor` to serve a Web UI for our Bull queues (e.g. Notifica
### Frontend ### Frontend
- In **development** mode, the Speckle Server will proxy the frontend from `localhost:3000` to `localhost:8080`. - In **development** mode, the Speckle Server will proxy the frontend from `127.0.0.1:3000` to `127.0.0.1:8080`.
If you don't see anything, ensure you've run `yarn dev` in the frontend package. If you don't see anything, ensure you've run `yarn dev` in the frontend package.
- In **production** mode, the frontend is served by an `nginx` container that proxy server requests to the server (depending on the requested path). For more information about making a production deployment, check out [our detailed guide](https://speckle.guide/dev/server-setup.html) - In **production** mode, the frontend is served by an `nginx` container that proxy server requests to the server (depending on the requested path). For more information about making a production deployment, check out [our detailed guide](https://speckle.guide/dev/server-setup.html)
### GraphIQL ### GraphIQL
A GraphIQL app is available for authenticated api exploration at `localhost:3000/explorer`. Note that for the authentication flow to work, you need to have the frontend running first. A GraphIQL app is available for authenticated api exploration at `127.0.0.1:3000/explorer`. Note that for the authentication flow to work, you need to have the frontend running first.
### GraphQL Playground ### GraphQL Playground
For non-authenticated api exploration, you can use the Graphql Playground which is available by default at `localhost:3000/graphql`. For non-authenticated api exploration, you can use the Graphql Playground which is available by default at `127.0.0.1:3000/graphql`.
## Testing ## Testing