nuxt-outfit 1.0.6 → 1.0.8
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/module.json
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useRuntimeConfig, useRequestEvent, useRequestHeaders } from "#imports";
|
|
2
2
|
import { appendHeader } from "h3";
|
|
3
|
-
import { parse, splitCookiesString as split } from "set-cookie-parser";
|
|
4
|
-
import { serialize } from "cookie";
|
|
5
3
|
export const useSpaHeaders = (additionalHeaders = {}) => {
|
|
6
4
|
if (process.client) {
|
|
7
5
|
return {
|
|
@@ -15,7 +13,14 @@ export const useSpaHeaders = (additionalHeaders = {}) => {
|
|
|
15
13
|
if (!Object.prototype.hasOwnProperty.call(headers, "referer")) {
|
|
16
14
|
headers.referer = `${headers.host}/${event.node.req.originalUrl}`;
|
|
17
15
|
}
|
|
18
|
-
const parseCookie = (cookies) => {
|
|
16
|
+
const parseCookie = async (cookies) => {
|
|
17
|
+
const [
|
|
18
|
+
{ parse, splitCookiesString: split },
|
|
19
|
+
{ serialize }
|
|
20
|
+
] = await Promise.all([
|
|
21
|
+
import("set-cookie-parser"),
|
|
22
|
+
import("cookie")
|
|
23
|
+
]);
|
|
19
24
|
return parse(split(cookies)).map((cookie) => serialize(cookie.name, cookie.value, cookie));
|
|
20
25
|
};
|
|
21
26
|
const serverOptions = {
|
|
@@ -23,11 +28,11 @@ export const useSpaHeaders = (additionalHeaders = {}) => {
|
|
|
23
28
|
...additionalHeaders,
|
|
24
29
|
...headers
|
|
25
30
|
},
|
|
26
|
-
// eslint-disable-next-line
|
|
27
31
|
async onResponse({ response }) {
|
|
28
32
|
const { status, headers: headers2 } = response;
|
|
29
33
|
if (goodResponses.includes(status)) {
|
|
30
|
-
|
|
34
|
+
const incomingHeaders = await parseCookie(headers2.get("set-cookie"));
|
|
35
|
+
appendHeader(event, "Set-Cookie", incomingHeaders);
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
};
|
|
@@ -3,8 +3,7 @@ import Echo from "laravel-echo";
|
|
|
3
3
|
export default defineNuxtPlugin(async (nuxtApp) => {
|
|
4
4
|
const options = useRuntimeConfig().public.outfit.echo;
|
|
5
5
|
if (options.broadcaster === "socket.io") {
|
|
6
|
-
|
|
7
|
-
options.client = io;
|
|
6
|
+
options.client = await import("socket.io-client");
|
|
8
7
|
}
|
|
9
8
|
nuxtApp.provide("echo", new Echo(options));
|
|
10
9
|
});
|