feat: Gitpod ready code(almost)
This commit is contained in:
parent
77ae070c98
commit
1c65df282e
3
apps/ui/src/app.d.ts
vendored
3
apps/ui/src/app.d.ts
vendored
@ -19,3 +19,6 @@ declare namespace App {
|
|||||||
privatePort: string;
|
privatePort: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare const GITPOD_WORKSPACE_URL: string
|
||||||
|
|
@ -1,8 +1,12 @@
|
|||||||
import { browser, dev } from '$app/env';
|
import { browser, dev } from '$app/env';
|
||||||
import Cookies from 'js-cookie';
|
import Cookies from 'js-cookie';
|
||||||
import { toast } from '@zerodevx/svelte-toast';
|
|
||||||
|
|
||||||
export function getAPIUrl() {
|
export function getAPIUrl() {
|
||||||
|
if (GITPOD_WORKSPACE_URL) {
|
||||||
|
const {href} = new URL(GITPOD_WORKSPACE_URL)
|
||||||
|
const newURL = href.replace('https://','https://3001-').replace(/\/$/,'')
|
||||||
|
return newURL
|
||||||
|
}
|
||||||
return dev ? 'http://localhost:3001' : 'http://localhost:3000';
|
return dev ? 'http://localhost:3001' : 'http://localhost:3000';
|
||||||
}
|
}
|
||||||
async function send({
|
async function send({
|
||||||
@ -52,7 +56,7 @@ async function send({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dev && !path.startsWith('https://')) {
|
if (dev && !path.startsWith('https://')) {
|
||||||
path = `http://localhost:3001${path}`;
|
path = `${getAPIUrl()}${path}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(`${path}`, opts);
|
const response = await fetch(`${path}`, opts);
|
||||||
|
@ -3,7 +3,20 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
|||||||
/** @type {import('vite').UserConfig} */
|
/** @type {import('vite').UserConfig} */
|
||||||
export default {
|
export default {
|
||||||
plugins: [sveltekit()],
|
plugins: [sveltekit()],
|
||||||
|
define: {
|
||||||
|
'GITPOD_WORKSPACE_URL': JSON.stringify(process.env.GITPOD_WORKSPACE_URL)
|
||||||
|
},
|
||||||
server: {
|
server: {
|
||||||
|
hmr: process.env.GITPOD_WORKSPACE_URL
|
||||||
|
? {
|
||||||
|
// Due to port fowarding, we have to replace
|
||||||
|
// 'https' with the forwarded port, as this
|
||||||
|
// is the URI created by Gitpod.
|
||||||
|
host: process.env.GITPOD_WORKSPACE_URL.replace("https://", "3000-"),
|
||||||
|
protocol: "wss",
|
||||||
|
clientPort: 443
|
||||||
|
}
|
||||||
|
: true,
|
||||||
fs: {
|
fs: {
|
||||||
allow: ['./src/lib/locales/']
|
allow: ['./src/lib/locales/']
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user