Files
Project-SDE-WP-Suite/feedback-config.js
n.siegfried 3d4402c88c Switch feedback reverse proxy from IIS to NGINX
- Add nginx-wp-suite.conf: static site + /api/feedback proxy to the Power
  Automate trigger (SNI on, Host header, POST-only, body cap)
- Remove IIS web.config
- Update feedback-config.js comment and DEPLOYMENT.md to the NGINX setup

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 10:46:35 -07:00

49 lines
2.6 KiB
JavaScript

/* ──────────────────────────────────────────────────────────────────────────
CENTRAL FEEDBACK CONFIGURATION
----------------------------------------------------------------------------
By default the suite stores all feedback in each user's own browser
(localStorage) and reviewers share it via Export / Import. That needs no
server and works behind any firewall.
To ALSO collect feedback automatically into one central place, set
FEEDBACK_ENDPOINT below to a URL that accepts an HTTP POST of JSON. This
works with either:
• a small backend on your host (Node/PHP/Python/ASP.NET) that appends the
body to a feedback.json / .csv you can download, or
• a Microsoft Power Automate "When an HTTP request is received" trigger
that writes to a SharePoint list / Excel table.
Leave it as an empty string to stay fully local (export/import only).
See DEPLOYMENT.md for setup details and sample receivers.
This is set to the same-origin path '/api/feedback', which the NGINX reverse
proxy (see nginx-wp-suite.conf) forwards to the Power Automate HTTP trigger.
Keeping it relative means no CORS and the secret trigger URL never appears in
client code. Locally (no proxy) the POST simply fails silently and feedback is
still saved/exported from the browser.
────────────────────────────────────────────────────────────────────────── */
window.FEEDBACK_ENDPOINT = '/api/feedback';
/* Best-effort send to the central endpoint. Never throws and never blocks the
UI: feedback is always saved locally first by the caller, so a failed or
disabled POST simply means "not centrally collected." Returns a Promise that
resolves true on success, false otherwise. */
window.postFeedback = function (payload) {
if (!window.FEEDBACK_ENDPOINT) return Promise.resolve(false);
try {
return fetch(window.FEEDBACK_ENDPOINT, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
app: 'Work Package Suite',
page: (typeof location !== 'undefined' && location.pathname) || '',
submittedAt: new Date().toISOString(),
...payload
}),
keepalive: true // allow the send to complete even if the page unloads
}).then(function (r) { return r.ok; }).catch(function () { return false; });
} catch (e) {
return Promise.resolve(false);
}
};