diff --git a/docs/API-Reference/editor/CodeHintManager.md b/docs/API-Reference/editor/CodeHintManager.md
index 653b60d6a4..ede9eae725 100644
--- a/docs/API-Reference/editor/CodeHintManager.md
+++ b/docs/API-Reference/editor/CodeHintManager.md
@@ -271,7 +271,7 @@ Test if a hint popup is open.
Register a handler to show hints at the top of the hint list.
This API allows extensions to add their own hints at the top of the standard hint list.
-**Kind**: inner method of [CodeHintManager](#module_CodeHintManager)
+**Kind**: inner method of [CodeHintManager](#module_CodeHintManager)
| Param | Type | Description |
| --- | --- | --- |
@@ -282,4 +282,4 @@ This API allows extensions to add their own hints at the top of the standard hin
### CodeHintManager.clearHintsAtTop()
Unregister the hints at top handler.
-**Kind**: inner method of [CodeHintManager](#module_CodeHintManager)
+**Kind**: inner method of [CodeHintManager](#module_CodeHintManager)
diff --git a/serve-proxy.js b/serve-proxy.js
index 93ca243ced..8c3d236e54 100644
--- a/serve-proxy.js
+++ b/serve-proxy.js
@@ -1,4 +1,5 @@
#!/usr/bin/env node
+/* eslint-env node */
const http = require('http');
const https = require('https');
@@ -7,6 +8,10 @@ const path = require('path');
const fs = require('fs');
const httpProxy = require('http-proxy');
+// Account server configuration - switch between local and production
+const ACCOUNT_SERVER = 'https://account.phcode.dev'; // Production
+// const ACCOUNT_SERVER = 'http://localhost:5000'; // Local development
+
// Default configuration
let config = {
port: 8000,
@@ -20,10 +25,10 @@ let config = {
// Parse command line arguments
function parseArgs() {
const args = process.argv.slice(2);
-
+
for (let i = 0; i < args.length; i++) {
const arg = args[i];
-
+
if (arg === '-p' && args[i + 1]) {
config.port = parseInt(args[i + 1]);
i++;
@@ -64,15 +69,15 @@ proxy.on('error', (err, req, res) => {
});
// Modify proxy request headers
-proxy.on('proxyReq', (proxyReq, req, res) => {
+proxy.on('proxyReq', (proxyReq, req) => {
// Transform localhost:8000 to appear as phcode.dev domain
- const originalHost = req.headers.host;
const originalReferer = req.headers.referer;
const originalOrigin = req.headers.origin;
-
+
// Set target host
- proxyReq.setHeader('Host', 'account.phcode.dev');
-
+ const accountHost = new URL(ACCOUNT_SERVER).hostname;
+ proxyReq.setHeader('Host', accountHost);
+
// Transform referer from localhost:8000 to phcode.dev
if (originalReferer && originalReferer.includes('localhost:8000')) {
const newReferer = originalReferer.replace(/localhost:8000/g, 'phcode.dev');
@@ -80,7 +85,7 @@ proxy.on('proxyReq', (proxyReq, req, res) => {
} else if (!originalReferer) {
proxyReq.setHeader('Referer', 'https://phcode.dev/');
}
-
+
// Transform origin from localhost:8000 to phcode.dev
if (originalOrigin && originalOrigin.includes('localhost:8000')) {
const newOrigin = originalOrigin.replace(/localhost:8000/g, 'phcode.dev');
@@ -88,18 +93,18 @@ proxy.on('proxyReq', (proxyReq, req, res) => {
} else if (!originalOrigin) {
proxyReq.setHeader('Origin', 'https://phcode.dev');
}
-
+
// Ensure HTTPS scheme
proxyReq.setHeader('X-Forwarded-Proto', 'https');
proxyReq.setHeader('X-Forwarded-For', req.connection.remoteAddress);
-
+
});
// Modify proxy response headers
proxy.on('proxyRes', (proxyRes, req, res) => {
// Pass through cache control and other security headers
// But translate any domain references back to localhost for the browser
-
+
const setCookieHeader = proxyRes.headers['set-cookie'];
if (setCookieHeader) {
// Transform any phcode.dev domain cookies back to localhost
@@ -108,7 +113,7 @@ proxy.on('proxyRes', (proxyRes, req, res) => {
});
proxyRes.headers['set-cookie'] = modifiedCookies;
}
-
+
// Ensure CORS headers if needed
if (config.cors) {
proxyRes.headers['Access-Control-Allow-Origin'] = '*';
@@ -148,7 +153,7 @@ function serveStaticFile(req, res, filePath) {
res.end('File not found');
return;
}
-
+
if (stats.isDirectory()) {
// Try to serve index.html from directory
const indexPath = path.join(filePath, 'index.html');
@@ -163,7 +168,7 @@ function serveStaticFile(req, res, filePath) {
res.end('Error reading directory');
return;
}
-
+
const html = `
@@ -178,24 +183,24 @@ function serveStaticFile(req, res, filePath) {