-
Notifications
You must be signed in to change notification settings - Fork 48
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
how to extra config to app #25
Comments
hi @wangfengyuan sorry for late reply. To achieve this, I prob should add in some sorta hook to the plugin. For now you could create a customize adapter to put in your configs: import { defineConfig } from 'vite';
import { VitePluginNode } from 'vite-plugin-node';
export default defineConfig({
plugins: [
...VitePluginNode({
adapter: async function (app, req, res) {
await app.init();
// your configs:
app.setGlobalPrefix('/api');
app.set('trust proxy', true);
app.disable('x-powered-by');
const instance = app.getHttpAdapter().getInstance();
instance(req, res);
},
appPath: './app.ts'
})
]
}); let me know if this works for you |
IMO, this is approach is more understandable and cleaner: import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function createNestApp() {
const app = await NestFactory.create(AppModule);
// Extra configuration
app.setGlobalPrefix('/base/');
app.set('trust proxy', true);
app.disable('x-powered-by');
// ....
return app;
}
if (process.env.NODE_ENV === 'production') {
createNestApp().then(async (app) => {
await app.listen(3000);
});
}
export const viteNodeApp = createNestApp(); I think updating the documentation with some examples would be a simpler solution compared to providing extra hooks. It would also be more flexible and can help keep the maintenance costs lower. |
@yusufkandemir yes it works, thanks for your suggestion |
after that, my extra config about app did not work,i want to know how to organize my code
The text was updated successfully, but these errors were encountered: