fix
This commit is contained in:
parent
b44e252cbb
commit
d962c0e9cd
@ -1,18 +1,49 @@
|
|||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import solidPlugin from "vite-plugin-solid";
|
import solidPlugin from "vite-plugin-solid";
|
||||||
import UnoCSS from "unocss/vite";
|
import UnoCSS from "unocss/vite";
|
||||||
|
import metadata from "./public/client-metadata.json";
|
||||||
|
|
||||||
const SERVER_HOST = "0.0.0.0";
|
const SERVER_HOST = "0.0.0.0";
|
||||||
const SERVER_PORT = 13213;
|
const SERVER_PORT = 13213;
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [UnoCSS(), solidPlugin()],
|
plugins: [
|
||||||
server: {
|
UnoCSS(),
|
||||||
host: SERVER_HOST,
|
solidPlugin(),
|
||||||
port: SERVER_PORT,
|
// Injects OAuth-related variables
|
||||||
allowedHosts: ['pds.syu.is'],
|
{
|
||||||
},
|
name: "oauth",
|
||||||
build: {
|
config(_conf, { command }) {
|
||||||
target: "esnext",
|
if (command === "build") {
|
||||||
},
|
process.env.VITE_OAUTH_CLIENT_ID = metadata.client_id;
|
||||||
|
process.env.VITE_OAUTH_REDIRECT_URL = metadata.redirect_uris[0];
|
||||||
|
} else {
|
||||||
|
const redirectUri = ((): string => {
|
||||||
|
const url = new URL(metadata.redirect_uris[0]);
|
||||||
|
return `http://${SERVER_HOST}:${SERVER_PORT}${url.pathname}`;
|
||||||
|
})();
|
||||||
|
|
||||||
|
const clientId =
|
||||||
|
`http://localhost` +
|
||||||
|
`?redirect_uri=${encodeURIComponent(redirectUri)}` +
|
||||||
|
`&scope=${encodeURIComponent(metadata.scope)}`;
|
||||||
|
|
||||||
|
process.env.VITE_DEV_SERVER_PORT = "" + SERVER_PORT;
|
||||||
|
process.env.VITE_OAUTH_CLIENT_ID = clientId;
|
||||||
|
process.env.VITE_OAUTH_REDIRECT_URL = redirectUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
process.env.VITE_CLIENT_URI = metadata.client_uri;
|
||||||
|
process.env.VITE_OAUTH_SCOPE = metadata.scope;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
server: {
|
||||||
|
host: SERVER_HOST,
|
||||||
|
port: SERVER_PORT,
|
||||||
|
allowedHosts: ['pds.syu.is'],
|
||||||
|
},
|
||||||
|
build: {
|
||||||
|
target: "esnext",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user