Skip to content

Instantly share code, notes, and snippets.

@cweinberger
Last active June 20, 2020 09:32
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 cweinberger/cfaec072b99c8514e7e296961039c23a to your computer and use it in GitHub Desktop.
Save cweinberger/cfaec072b99c8514e7e296961039c23a to your computer and use it in GitHub Desktop.
Vapor 4 TodoBackend - CORS Middleware
public func configure(_ app: Application) throws {
// Serves files from `Public/` directory
// app.middleware.use(FileMiddleware(publicDirectory: app.directory.publicDirectory))
app.middleware.use(CORSMiddleware()) // Add CORS with default configuration
// Configure SQLite database
app.databases.use(.sqlite(.file("db.sqlite")), as: .sqlite)
// Configure migrations
app.migrations.add(CreateTodo())
try app.autoMigrate().wait() // enable auto migrate
try routes(app)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment