submits correctly now using variables set in the service from secrets.

This commit is contained in:
2025-12-18 23:00:43 +00:00
parent 04f6da76e7
commit 16f88f9031
3 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -202,7 +202,7 @@
data.pbToken = pb.authStore.token;
try {
const response = await fetch('/idea-feedback/api/submit', {
const response = await fetch('/api/submit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
+1 -1
View File
@@ -4,7 +4,7 @@
"description": "Idea and Feedback Form with PocketBase",
"type": "module",
"scripts": {
"dev": "bun run server.ts",
"dev": "PORT=7001 bun run server.ts",
"start": "bun run server.ts"
},
"dependencies": {
+5 -5
View File
@@ -2,9 +2,6 @@ import { Hono } from 'hono';
import { serveStatic } from 'hono/bun';
import { cors } from 'hono/cors';
import PocketBase from 'pocketbase';
import { config } from 'dotenv';
config();
const app = new Hono();
@@ -14,9 +11,12 @@ app.use('/*', cors());
// Serve static files from frontend directory
app.use('/*', serveStatic({ root: './frontend' }));
// PocketBase client
// PocketBase client - PB_DB from service environment
const pb = new PocketBase(process.env.PB_DB || 'https://pocketbase.ccllc.pro');
// Collection name from service env (fallback to Ideas_Feedback)
const PB_IDEA_COLLECTION = process.env.PBIdea_Collection || 'Ideas_Feedback';
// Use user's PocketBase token (passed from authenticated frontend)
function setUserPocketBaseAuth(token: string) {
pb.authStore.save(token);
@@ -41,7 +41,7 @@ app.post('/api/submit', async (c) => {
delete data.pbToken;
// Create the record in PocketBase as the authenticated user
const record = await pb.collection(process.env.PB_COLLECTION!).create(data);
const record = await pb.collection(PB_IDEA_COLLECTION).create(data);
console.log(`✓ Created PocketBase record with ID: ${record.id}`);
return c.json({