wiki-plugin-shoppe 0.0.40 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/server/server.js +13 -0
package/package.json
CHANGED
package/server/server.js
CHANGED
|
@@ -3005,6 +3005,19 @@ async function startServer(params) {
|
|
|
3005
3005
|
if (!fs.existsSync(TMP_DIR)) fs.mkdirSync(TMP_DIR, { recursive: true });
|
|
3006
3006
|
console.log('🛍️ wiki-plugin-shoppe starting...');
|
|
3007
3007
|
|
|
3008
|
+
// Allow Shoppere desktop/mobile app (tauri://localhost) to call our JSON API
|
|
3009
|
+
const SHOPPERE_ORIGINS = ['tauri://localhost', 'https://tauri.localhost'];
|
|
3010
|
+
app.use('/plugin/shoppe', (req, res, next) => {
|
|
3011
|
+
const origin = req.headers.origin;
|
|
3012
|
+
if (origin && SHOPPERE_ORIGINS.includes(origin)) {
|
|
3013
|
+
res.setHeader('Access-Control-Allow-Origin', origin);
|
|
3014
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
3015
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
3016
|
+
if (req.method === 'OPTIONS') return res.sendStatus(200);
|
|
3017
|
+
}
|
|
3018
|
+
next();
|
|
3019
|
+
});
|
|
3020
|
+
|
|
3008
3021
|
const owner = (req, res, next) => {
|
|
3009
3022
|
if (!app.securityhandler.isAuthorized(req)) {
|
|
3010
3023
|
return res.status(401).json({ error: 'must be owner' });
|