Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Extiri Web Environment Variables
#
# Copy this file to .env and adjust values as needed.
# Environment variables prefixed with PUBLIC_ are exposed to the client.

# Base URL for the Extiri API (no trailing slash)
PUBLIC_API_BASE_URL=https://extiri.com
7 changes: 4 additions & 3 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import escape from 'lodash.escape';
import md5 from 'md5';
import CodeMirror from '../CodeMirror.svelte';
import { PUBLIC_API_BASE_URL } from '$env/static/public';

const browser = typeof localStorage !== 'undefined';

Expand Down Expand Up @@ -176,7 +177,7 @@
async function getSnippets() {
isLoading = true;

let api = 'https://extiri.com/api/1/snippets/?';
let api = `${PUBLIC_API_BASE_URL}/api/1/snippets/?`;

api = api + 'page=' + currentPage;

Expand Down Expand Up @@ -307,7 +308,7 @@
async function getUserDetail() {
let token = getToken();

let response = await fetch('https://extiri.com/api/1/users/me/', {
let response = await fetch(`${PUBLIC_API_BASE_URL}/api/1/users/me/`, {
headers: { Authorization: 'Bearer ' + token }
});

Expand Down Expand Up @@ -361,7 +362,7 @@
<header class="store-header">
<div class="store-header__brand">
<button class="store-logo" on:click={() => goto('/')}>Snippex</button>
<span class="store-header__byline">Crafted by <a href="https://extiri.com" target="_blank" rel="noreferrer"><img style="height: 15px !important; display: inline;" src="/extiri-text-only.png" alt="Extiri logo" /></a></span>
<span class="store-header__byline">Crafted by <a href={PUBLIC_API_BASE_URL} target="_blank" rel="noreferrer"><img style="height: 15px !important; display: inline;" src="/extiri-text-only.png" alt="Extiri logo" /></a></span>
</div>
<div class="store-header__actions">
{#if isLoggedIn}
Expand Down
11 changes: 6 additions & 5 deletions src/routes/account/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { goto } from '$app/navigation';
import md5 from 'md5';
import escape from 'lodash.escape';
import { PUBLIC_API_BASE_URL } from '$env/static/public';

const browser = typeof window !== 'undefined';

Expand Down Expand Up @@ -72,7 +73,7 @@
password: newUserPassword
};

let response = await fetch('https://extiri.com/api/1/users/signup/', {
let response = await fetch(`${PUBLIC_API_BASE_URL}/api/1/users/signup/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
Expand Down Expand Up @@ -106,7 +107,7 @@
password: loginPassword
};

let response = await fetch('https://extiri.com/api/1/users/delete/', {
let response = await fetch(`${PUBLIC_API_BASE_URL}/api/1/users/delete/`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
Expand Down Expand Up @@ -148,7 +149,7 @@

let encodedCredentials = window.btoa(credentials.email + ':' + credentials.password);

let response = await fetch('https://extiri.com/api/1/users/login/', {
let response = await fetch(`${PUBLIC_API_BASE_URL}/api/1/users/login/`, {
method: 'POST',
headers: {
Authorization: 'Basic ' + encodedCredentials,
Expand Down Expand Up @@ -215,7 +216,7 @@
async function getUserDetail() {
let token = getToken();

let response = await fetch('https://extiri.com/api/1/users/me/', {
let response = await fetch(`${PUBLIC_API_BASE_URL}/api/1/users/me/`, {
headers: {
Authorization: 'Bearer ' + token
}
Expand Down Expand Up @@ -390,7 +391,7 @@
<input type="checkbox" bind:checked={agreedToTermsOfService} />
<span
>I agree to the
<a href="https://extiri.com/codemenu/terms_of_services.html" target="_blank" rel="noreferrer"
<a href={`${PUBLIC_API_BASE_URL}/codemenu/terms_of_services.html`} target="_blank" rel="noreferrer"
>Terms of Service</a
>.</span
>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/create/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import CodeMirror from '../../CodeMirrorEditor.svelte';
import { languages } from '../../langStyles.js';
import { languageStore } from '../../store.js';
import { PUBLIC_API_BASE_URL } from '$env/static/public';

const categories = ['None', 'UI', 'Math', 'Collections', 'Automations', 'Debugging'];

Expand Down Expand Up @@ -51,7 +52,7 @@
code: code
};

let response = await fetch('https://extiri.com/api/1/snippets/create/', {
let response = await fetch(`${PUBLIC_API_BASE_URL}/api/1/snippets/create/`, {
method: 'POST',
headers: {
Authorization: 'Bearer ' + getToken(),
Expand Down
9 changes: 5 additions & 4 deletions src/routes/snippet/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@
import escape from 'lodash.escape';
import CodeMirror from '../../CodeMirror.svelte';
import sdk from '@stackblitz/sdk';
import { PUBLIC_API_BASE_URL } from '$env/static/public';

const browser = typeof window !== 'undefined';

Expand Down Expand Up @@ -522,7 +523,7 @@
}

async function getUser(id: string) {
let response = await fetch('https://extiri.com/api/1/users/get/' + id);
let response = await fetch(`${PUBLIC_API_BASE_URL}/api/1/users/get/` + id);

if (response.ok) {
let user = await (response.json() as Promise<User>);
Expand All @@ -536,7 +537,7 @@
async function getSnippetsDetail() {
if (browser) {
id = window.location.toString().split('?')[1];
let response = await fetch('https://extiri.com/api/1/snippets/get/' + id);
let response = await fetch(`${PUBLIC_API_BASE_URL}/api/1/snippets/get/` + id);

if (response.ok) {
let snippet = await (response.json() as Promise<Snippet>);
Expand All @@ -562,7 +563,7 @@
}

id = window.location.toString().split('?')[1];
let response = await fetch('https://extiri.com/api/1/snippets/delete/' + id, {
let response = await fetch(`${PUBLIC_API_BASE_URL}/api/1/snippets/delete/` + id, {
method: 'DELETE',
headers: { Authorization: 'Bearer ' + getToken() }
});
Expand Down Expand Up @@ -592,7 +593,7 @@
async function checkIfCreator() {
let token = getToken();

let response = await fetch('https://extiri.com/api/1/users/me/', {
let response = await fetch(`${PUBLIC_API_BASE_URL}/api/1/users/me/`, {
headers: { Authorization: 'Bearer ' + token }
});

Expand Down