Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"fmt.configPath": null
}
}
},
"oxlint": {
"binary": {
"path": "mise",
"arguments": ["exec", "--", "oxlint", "--lsp"]
}
}
},
"languages": {
Expand Down
8 changes: 1 addition & 7 deletions packages/graphql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,7 @@ const fillOptions = (opt: YogaServerOptions): Required<YogaServerOptions> => ({
mailer: opt?.mailer ?? mockTransport(),
emailFrom: opt?.emailFrom ?? "[email protected]",
// FIXME: Properly parametrize the following allowlist:
origins:
opt?.origins ??
new Set([
"https://drfed.org",
"http://localhost:3000",
"http://0.0.0.0:3000",
]),
origins: opt?.origins ?? new Set(["https://drfed.org"]),
});

const getAccessToken = (headers: Headers) =>
Expand Down
1 change: 0 additions & 1 deletion packages/web/.env.example

This file was deleted.

2 changes: 1 addition & 1 deletion packages/web/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
interface ImportMetaEnv {
readonly VITE_DRFED_URL: string;
VITE_BACKEND_URL: string;
}

interface ImportMeta {
Expand Down
8 changes: 7 additions & 1 deletion packages/web/src/RelayEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ const fetchFn: FetchFunction = async (params, variables) => {
if (accessToken !== undefined) {
headers.Authorization = `Bearer ${accessToken}`;
}
const response = await fetch(import.meta.env.VITE_DRFED_URL, {

const url = new URL(
"/graphql",
event?.request.url ?? globalThis.location.href,
);

const response = await fetch(url, {
method: "POST",
headers,
body: JSON.stringify({
Expand Down
38 changes: 26 additions & 12 deletions packages/web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,34 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import process from "node:process";

import { solidStart } from "@solidjs/start/config";
import { nitro } from "nitro/vite";
import { defineConfig } from "vite";
import { defineConfig, loadEnv } from "vite";
import { cjsInterop } from "vite-plugin-cjs-interop";
import relay from "vite-plugin-relay-lite";

export default defineConfig(({ command }) => ({
plugins: [
solidStart(),
nitro(),
relay({ codegen: command !== "build" }),
{
...cjsInterop({ dependencies: ["relay-runtime"] }),
applyToEnvironment: (environment) => environment.name === "ssr",
},
],
}));
export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd());
return {
plugins: [
solidStart(),
nitro({
routeRules: {
"/graphql": {
proxy: {
to: `${env.VITE_BACKEND_URL}/graphql`,
forwardHeaders: ["accept"],
},
},
},
}),
relay({ codegen: command !== "build" }),
{
...cjsInterop({ dependencies: ["relay-runtime"] }),
applyToEnvironment: (environment) => environment.name === "ssr",
},
],
};
});