dont use cookies

This commit is contained in:
daniel-j
2024-10-20 21:26:19 +02:00
parent f1b37ea02d
commit 34e5854c43
3 changed files with 9 additions and 4 deletions

View File

@@ -166,6 +166,7 @@ router.post('/generate', async ctx => {
ctx.body = key ctx.body = key
}) })
/*
router.get('/download/:key', async ctx => { router.get('/download/:key', async ctx => {
const key = ctx.cookies.get('key') const key = ctx.cookies.get('key')
if (!key) { if (!key) {
@@ -182,13 +183,15 @@ router.get('/download/:key', async ctx => {
ctx.redirect('/' + encodeURIComponent(info.file.name)); ctx.redirect('/' + encodeURIComponent(info.file.name));
}) })
*/
async function downloadFile (ctx, next) { async function downloadFile (ctx, next) {
const key = ctx.cookies.get('key') const key = ctx.query.key
if (!key) { if (!key) {
await next() await next()
return return
} }
const filename = decodeURIComponent(ctx.params.filename) const filename = decodeURIComponent(ctx.params.filename)
const info = ctx.keys.get(key) const info = ctx.keys.get(key)
@@ -544,7 +547,7 @@ router.get('/status/:key', async ctx => {
return return
} }
expireKey(key) expireKey(key)
ctx.cookies.set('key', key, {overwrite: true, httpOnly: false, sameSite: 'strict', maxAge: expireDelay * 1000}) // ctx.cookies.set('key', key, {overwrite: true, httpOnly: false, sameSite: 'strict', maxAge: expireDelay * 1000})
ctx.body = { ctx.body = {
alive: info.alive, alive: info.alive,
file: info.file ? { file: info.file ? {

View File

@@ -39,6 +39,7 @@
Visit this on other devices to send ebooks to this ereader:<br/><a id="siteurl">https://send.djazz.se</a><br/> Visit this on other devices to send ebooks to this ereader:<br/><a id="siteurl">https://send.djazz.se</a><br/>
<br/> <br/>
Created by djazz. Source code on <a href="https://github.com/daniel-j/send2ereader" target="_blank">Github</a><br/> Created by djazz. Source code on <a href="https://github.com/daniel-j/send2ereader" target="_blank">Github</a><br/>
Last updated: 2024-10-20<br/>
</div> </div>
</div> </div>
@@ -81,7 +82,7 @@ function pollFile () {
if (data.file) { if (data.file) {
downloads.style.display = 'block' downloads.style.display = 'block'
downloadlink.textContent = data.file.name downloadlink.textContent = data.file.name
downloadlink.href = '/' + encodeURIComponent(data.file.name) downloadlink.href = '/' + encodeURIComponent(data.file.name) + "?key=" + key
} else { } else {
downloads.style.display = 'none' downloads.style.display = 'none'
} }

View File

@@ -33,7 +33,8 @@
<hr/> <hr/>
<div class="center"> <div class="center">
Created by djazz. Powered by <a href="https://koajs.com/" target="_blank">Koa</a>, <a href="https://pgaskin.net/kepubify/" target="_blank">Kepubify</a>, <a href="https://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211" target="_blank">KindleGen</a> and <a href="https://github.com/abarker/pdfCropMargins" target="_blank">pdfCropMargins</a><br/> Created by djazz. Powered by <a href="https://koajs.com/" target="_blank">Koa</a>, <a href="https://pgaskin.net/kepubify/" target="_blank">Kepubify</a>, <a href="https://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211" target="_blank">KindleGen</a> and <a href="https://github.com/abarker/pdfCropMargins" target="_blank">pdfCropMargins</a><br/>
Source code on <a href="https://github.com/daniel-j/send2ereader" target="_blank">Github</a> - <a id="siteurl">https://send.djazz.se</span> Source code on <a href="https://github.com/daniel-j/send2ereader" target="_blank">Github</a> - <a id="siteurl">https://send.djazz.se</a><br/>
Last updated: 2024-10-20
</div> </div>
</div> </div>