@makeswift/runtime 0.2.5 → 0.2.7
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/dist/index.cjs.js +11 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +11 -2
- package/dist/index.es.js.map +1 -1
- package/dist/types/src/next/api-handler.d.ts.map +1 -1
- package/dist/types/src/utils/isErrorWithMessage.d.ts +6 -0
- package/dist/types/src/utils/isErrorWithMessage.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1002,7 +1002,10 @@ class Document$1 extends NextDocument__default["default"] {
|
|
|
1002
1002
|
});
|
|
1003
1003
|
}
|
|
1004
1004
|
}
|
|
1005
|
-
const version = "0.2.
|
|
1005
|
+
const version = "0.2.7";
|
|
1006
|
+
function isErrorWithMessage(error) {
|
|
1007
|
+
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
1008
|
+
}
|
|
1006
1009
|
function MakeswiftApiHandler(apiKey, { appOrigin = "https://app.makeswift.com", getFonts } = {}) {
|
|
1007
1010
|
const cors = Cors__default["default"]({ origin: appOrigin });
|
|
1008
1011
|
const previewModeProxy = httpProxy.createProxyServer();
|
|
@@ -1060,6 +1063,9 @@ Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-r
|
|
|
1060
1063
|
await revalidate(req.query.path);
|
|
1061
1064
|
return res.json({ revalidated: true });
|
|
1062
1065
|
} catch (error) {
|
|
1066
|
+
if (isErrorWithMessage(error)) {
|
|
1067
|
+
return res.status(500).json({ message: error.message });
|
|
1068
|
+
}
|
|
1063
1069
|
return res.status(500).json({ message: "Error Revalidating" });
|
|
1064
1070
|
}
|
|
1065
1071
|
}
|
|
@@ -1070,7 +1076,10 @@ Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-r
|
|
|
1070
1076
|
if (host == null)
|
|
1071
1077
|
return res.status(400).send("Bad Request");
|
|
1072
1078
|
const forwardedProto = req.headers["x-forwarded-proto"];
|
|
1073
|
-
const
|
|
1079
|
+
const isForwardedProtoHttps = typeof forwardedProto === "string" && forwardedProto === "https";
|
|
1080
|
+
const forwardedSSL = req.headers["x-forwarded-ssl"];
|
|
1081
|
+
const isForwardedSSL = typeof forwardedSSL === "string" && forwardedSSL === "on";
|
|
1082
|
+
const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
|
|
1074
1083
|
let target = `${proto}://${host}`;
|
|
1075
1084
|
if (process.env["NODE_ENV"] !== "production") {
|
|
1076
1085
|
const port = req.socket.localPort;
|