Last active
June 20, 2020 09:32
-
-
Save cweinberger/cfaec072b99c8514e7e296961039c23a to your computer and use it in GitHub Desktop.
Vapor 4 TodoBackend - CORS Middleware
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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