Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Remix #12

Open
Marcisbee opened this issue Jan 13, 2023 · 14 comments
Open

Support for Remix #12

Marcisbee opened this issue Jan 13, 2023 · 14 comments
Labels
enhancement New feature or request priority This feature is one of a priority work

Comments

@Marcisbee
Copy link

Any plans to support Remix with custom server adapter similar to @remix-run/express?

@SaltyAom
Copy link
Member

Sure, I love Remix.

Added to roadmap

@SaltyAom
Copy link
Member

Blocking on: oven-sh/bun#1864

@SaltyAom SaltyAom added the blocking Blocked by other issues label Feb 10, 2023
@Marcisbee
Copy link
Author

Marcisbee commented Feb 16, 2023

Is this unblocked now via this PR?

@SaltyAom
Copy link
Member

Likely yes, will continue working on an adapter after the PR landed on stable (likely Bun 0.5.7)

@SaltyAom SaltyAom added priority This feature is one of a priority work enhancement New feature or request and removed blocking Blocked by other issues labels Feb 23, 2023
@tobimori
Copy link

any update? :)

@rashidtvmr
Copy link

any update?

@wladpaiva
Copy link

Apparently elysia + remix is already supported. You just need to make some tweeks
https://github.com/wladiston/elysia-remix

@TaQuanMinhLong
Copy link

I did also manage to make it work, though only with production mode

// plugins/remix.ts
import type { ServerBuild } from "@remix-run/node";
import { createRequestHandler } from "@remix-run/node";
import { join, parse } from "path";
import { Elysia } from "elysia";

export type RemixPlugin<T extends ServerBuild = any> = (
  serverBuild: T,
  publicDir?: string
) => Elysia;

export const remix: RemixPlugin = (serverBuild, publicDir = join(process.cwd(), "public")) =>
  new Elysia().all("*", async function ({ request, store, path, set }) {
    if (request.method === "GET" && parse(path).ext) {
      const filepath = join(publicDir, path);
      const file = Bun.file(filepath);
      const fileExist = await file.exists();
      if (!fileExist) {
        set.status = 404;
        return { error: "Requested resource does not exist" };
      }
      set.headers["Cache-Control"] = "public,max-age=31536000,immutable";
      return file;
    }
    /**
     * This only works for production build
     *
     * For development use remix dev instead
     */
    const handleRequest = createRequestHandler(serverBuild, "production");
    return await handleRequest(request, store);
  });
// server.ts
import { remix, logger } from "./plugins";
import { Elysia } from "elysia";
import * as build from "./build/index";

const port = process.env.PORT;

const app = new Elysia()
  .state("appLoadContext", "test")
  .use(logger())
  .use(remix(build))
  .listen(port ? Number(port) : 3000);

console.log(`Server is running at http://${app.server?.hostname}:${app.server?.port}`);
// Axios accept-encoding header should be set to gzip to work
...
headers: {
    common: {
      "Accept-Encoding": "gzip",
    },
  },
...

I'n not sure about this but after few clicks to test the router link, i feel that running original remix with bun is still somehow smoother than running remix by elysia 😂 It could be my implementation broke somewhere

@sabinpuiu
Copy link

Any update for official remix support?

@Danieljs-codes
Copy link

Any update for official remix support 🥹

@sigmachirality
Copy link

+1

2 similar comments
@Danieljs-codes
Copy link

+1

@ZorikovPasha
Copy link

+1

@stephen776
Copy link

Is there any current path here that works now that remix uses vite?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority This feature is one of a priority work
Projects
None yet
Development

No branches or pull requests