1 | import { BASE_URL } from '@env'
|
2 |
|
3 |
|
4 | import ShareDB from 'sharedb/lib/client'
|
5 |
|
6 |
|
7 | import commonInit from './common'
|
8 |
|
9 |
|
10 | if (!BASE_URL) {
|
11 | console.error(`
|
12 | !!!WARNING!!! No BASE_URL specified in .env
|
13 |
|
14 | Please read below how to fix:
|
15 |
|
16 | BASE_URL is not specified.
|
17 | Please create a file '.env.local' with BASE_URL of your machine/server:
|
18 |
|
19 | BASE_URL="http://YOUR_MACHINE_IP:3000"
|
20 |
|
21 | When developing locally, make sure YOUR_MACHINE_IP is not localhost but the actual IP address
|
22 | on your local network (like 192.168.0.100). Your smartphone should be connected to the same
|
23 | network as your machine. The native app will use YOUR_MACHINE_IP to connect to your local server.
|
24 |
|
25 | By default the server is configured to run on port 3000, so if you didn't change the PORT of the server, make
|
26 | sure to specify ':3000' in the BASE_URL.
|
27 |
|
28 | When running a production build, specify the proper BASE_URL in a '.env.production' file:
|
29 |
|
30 | BASE_URL="https://example.com"
|
31 | `)
|
32 | }
|
33 |
|
34 |
|
35 |
|
36 | process.title = 'browser'
|
37 |
|
38 |
|
39 | process.nextTick = process.nextTick || setImmediate
|
40 |
|
41 |
|
42 | window.__racerHighwayClientOptions = {
|
43 | base: '/channel',
|
44 | reconnect: true,
|
45 | browserChannelOnly: false,
|
46 | srvProtocol: getProtocol(),
|
47 | srvHost: getHost(),
|
48 | srvPort: getPort(),
|
49 | srvSecurePort: getPort(),
|
50 | timeout: 10000,
|
51 | timeoutIncrement: 10000
|
52 | }
|
53 | function getHost () {
|
54 | return (BASE_URL.match(/\/\/([^/:]+)/) || [])[1] || 'localhost'
|
55 | }
|
56 | function getProtocol () {
|
57 | return /https:/.test(BASE_URL) ? 'https:' : 'http:'
|
58 | }
|
59 | function getPort () {
|
60 | let port = ~~(BASE_URL.match(/:(\d+)/) || [])[1]
|
61 | if (!port) {
|
62 | let protocol = getProtocol()
|
63 | port = protocol === 'https:' ? 443 : 80
|
64 | }
|
65 | return port
|
66 | }
|
67 |
|
68 | commonInit(ShareDB)
|