#express+remix

1 messages · Page 1 of 1 (latest)

gleaming river
#

i have this problem.
express cant load assets.


import 'reflect-metadata'; // Не забудьте импортировать это
import express from 'express';
import { useExpressServer } from 'routing-controllers';
import { WorkerController } from './controllers/teacher.controller';
import { StudentController } from './controllers/student.controller';
import cors from 'cors'; 
import { userController } from './controllers/user.controller';
import { ServiceController } from './controllers/service.controller';
import { createRequestHandler } from '@remix-run/express';

const app = express();
const corsOptions = {
    origin: ['http://localhost:3000'],
    methods: ["GET,HEAD,PUT,PATCH,POST,DELETE"],
    headers: ['*'],
    credentials: true, // Enable cookies and other credentials
  };
app.use(cors(corsOptions));
app.use(express.static("public", { maxAge: "1h" }));
app.use(express.static("public/build", { immutable: true, maxAge: "1y" }));
app.all(
  "*",
  createRequestHandler({
    build: require("./../../test/public/build/build"),
    getLoadContext: () => ({

    }),
  })
)
useExpressServer(app, {
  cors: {
    origin: ['http://localhost:3000'],
    methods: ["GET,HEAD,PUT,PATCH,POST,DELETE"],
    headers: ['*'],
    credentials: true,
  },
  controllers: [WorkerController,ServiceController,StudentController,userController],
});

const PORT = process.env.PORT || 3001;
app.listen(PORT, () => {
  console.log(`Server is running on port ${PORT}`);
});

/** @type {import('@remix-run/dev').AppConfig} */
module.exports = {
  ignoredRouteFiles: ["**/.*"]m,
  serverBuildTarget: "express",
  browserBuildDirectory: "public/build",
  assetsBuildDirectory: "public/build",
  publicPath: "/build/",
  serverBuildPath: "build",
  tailwind: true,
  serverModuleFormat: "cjs",
  future: {
    Port: 3001,
    v2_dev: true,
    v2_errorBoundary: true,
    v2_headers: true,
    v2_meta: true,
    v2_normalizeFormMethod: true,
    v2_routeConvention: true,
  },
};
tardy haven
#

I assume this part was a copy paste error when pasting into discord but just checking ignoredRouteFiles: ["**/.*"]m,

#

How are you adding the tailwind stylesheet to your page?

#

eg: in the root.tsx, importing and passing to links?

gleaming river
#

import stylesheet from "~/tailwind.css";
export const links: LinksFunction = () => [
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
{ rel: "stylesheet", href: stylesheet },
];

tardy haven
#

ok that looks right, what happens when you click on the tailwind-3ZPUSWL.css? Is it just returning a 404?

#

Or is it there but just not including any of your styles?

#

If it's just the styles that are missing, make sure you have in your tailwind.config.js file content: ["./app/**/*.{js,jsx,ts,tsx}"],

tardy haven
#

Ok and in your /tailwind.css file in your source, do you have these three lines at the top?

@tailwind base;
@tailwind components;
@tailwind utilities;
gleaming river
#

yea true

tardy haven
gleaming river
gleaming river
#

idk whats wrong can be 😦