Allow setting a custom path for the UI (#23)
* Allow setting a custom path for the UI Allow defining an admin path in src/index.ts, which allows the base domain to be used as a redirect source. * lint * fix form when key is empty
This commit is contained in:
parent
0390a8d20a
commit
61df52e4f0
2 changed files with 6 additions and 3 deletions
|
|
@ -183,7 +183,8 @@
|
|||
const value = document.getElementById('value').value
|
||||
const password = document.getElementById('password').value
|
||||
|
||||
const url = key === '' ? window.location.href : window.location.href + key
|
||||
const baseUrlPath = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') + '/'
|
||||
const url = key === '' ? window.location.href : baseUrlPath + key
|
||||
const method = key === '' ? 'POST' : 'PUT'
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import * as st from 'simple-runtypes'
|
|||
// html.d.ts tells typescript that this is a normal thing to do
|
||||
import creationPageHtml from './form.html'
|
||||
|
||||
const ADMIN_PATH = '/'
|
||||
|
||||
type Variables = {
|
||||
path: string
|
||||
key: string
|
||||
|
|
@ -87,7 +89,7 @@ app.use('*', async (c, next) => {
|
|||
})
|
||||
|
||||
// retrieve list of keys
|
||||
app.get('/', async (c) => {
|
||||
app.get(ADMIN_PATH, async (c) => {
|
||||
if (c.req.header('Authorization')) {
|
||||
if (!checkAuth(c)) {
|
||||
return unauthorized(c)
|
||||
|
|
@ -171,7 +173,7 @@ app.delete('*', async (c) => {
|
|||
app.put('*', createLink)
|
||||
|
||||
// add random key
|
||||
app.post('/', async (c) => {
|
||||
app.post(ADMIN_PATH, async (c) => {
|
||||
const rawBody = await c.req.text()
|
||||
|
||||
if (!rawBody) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue