Build a Twitter Clone With Adonis and Vue

Enabling CORS

AdonisJs makes dealing with Cross-Origin Resource Sharing (CORS) a breeze, as it provide a package which we can use to handle CORS on our API. Because we used the api-only boilerplate while creating our app, the CORS package is already installed and setup for us. All we have to do now is configure it. The package comes with a configuration file which is located in config/cors.js. Open it and update the options as below:

// config/cors.js

// Allow current request origin
origin: true,

// HTTP methods to be allowed
methods: ['GET', 'PUT', 'POST', 'DELETE'],