@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.es.js
CHANGED
|
@@ -967,7 +967,10 @@ class Document$1 extends NextDocument {
|
|
|
967
967
|
});
|
|
968
968
|
}
|
|
969
969
|
}
|
|
970
|
-
const version = "0.2.
|
|
970
|
+
const version = "0.2.7";
|
|
971
|
+
function isErrorWithMessage(error) {
|
|
972
|
+
return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
|
|
973
|
+
}
|
|
971
974
|
function MakeswiftApiHandler(apiKey, { appOrigin = "https://app.makeswift.com", getFonts } = {}) {
|
|
972
975
|
const cors = Cors({ origin: appOrigin });
|
|
973
976
|
const previewModeProxy = createProxyServer();
|
|
@@ -1025,6 +1028,9 @@ Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-r
|
|
|
1025
1028
|
await revalidate(req.query.path);
|
|
1026
1029
|
return res.json({ revalidated: true });
|
|
1027
1030
|
} catch (error) {
|
|
1031
|
+
if (isErrorWithMessage(error)) {
|
|
1032
|
+
return res.status(500).json({ message: error.message });
|
|
1033
|
+
}
|
|
1028
1034
|
return res.status(500).json({ message: "Error Revalidating" });
|
|
1029
1035
|
}
|
|
1030
1036
|
}
|
|
@@ -1035,7 +1041,10 @@ Read more here: https://nextjs.org/blog/next-12-2#on-demand-incremental-static-r
|
|
|
1035
1041
|
if (host == null)
|
|
1036
1042
|
return res.status(400).send("Bad Request");
|
|
1037
1043
|
const forwardedProto = req.headers["x-forwarded-proto"];
|
|
1038
|
-
const
|
|
1044
|
+
const isForwardedProtoHttps = typeof forwardedProto === "string" && forwardedProto === "https";
|
|
1045
|
+
const forwardedSSL = req.headers["x-forwarded-ssl"];
|
|
1046
|
+
const isForwardedSSL = typeof forwardedSSL === "string" && forwardedSSL === "on";
|
|
1047
|
+
const proto = isForwardedProtoHttps || isForwardedSSL ? "https" : "http";
|
|
1039
1048
|
let target = `${proto}://${host}`;
|
|
1040
1049
|
if (process.env["NODE_ENV"] !== "production") {
|
|
1041
1050
|
const port = req.socket.localPort;
|