Skip to content

Instantly share code, notes, and snippets.

@jtoar

jtoar/server.ts Secret

Last active February 16, 2024 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtoar/57f7c9a73d0207e064a37f92eb9817d2 to your computer and use it in GitHub Desktop.
Save jtoar/57f7c9a73d0207e064a37f92eb9817d2 to your computer and use it in GitHub Desktop.
Serving both sides in the server file
// Make sure to add the `@redwoodjs/project-config` and `@redwoodjs/web-server` packages to the api side:
//
// ```bash
// yarn workspace api add @redwoodjs/project-config @redwoodjs/web-server
// ```
import { createServer } from '@redwoodjs/api-server'
import { getConfig } from '@redwoodjs/project-config'
import { handler as serveWeb } from '@redwoodjs/web-server'
import { logger } from 'src/lib/logger'
async function main() {
const server = await createServer({
logger,
})
await Promise.all([
serveWeb({
host: '0.0.0.0',
port: 8910,
apiUrl: getConfig().web.apiUrl,
// Update this to where your api server will be running
apiProxyTarget: 'http://0.0.0.0:8911',
}),
server.start(),
])
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment