{"action":"created","issue":{"url":"https://api.github.com/repos/MasoniteFramework/core/issues/320","repository_url":"https://api.github.com/repos/MasoniteFramework/core","labels_url":"https://api.github.com/repos/MasoniteFramework/core/issues/320/labels{/name}","comments_url":"https://api.github.com/repos/MasoniteFramework/core/issues/320/comments","events_url":"https://api.github.com/repos/MasoniteFramework/core/issues/320/events","html_url":"https://github.com/MasoniteFramework/core/issues/320","id":358583136,"node_id":"MDU6SXNzdWUzNTg1ODMxMzY=","number":320,"title":"Implement CORS Middleware","user":{"login":"theodesp","id":328805,"node_id":"MDQ6VXNlcjMyODgwNQ==","avatar_url":"https://avatars0.githubusercontent.com/u/328805?v=4","gravatar_id":"","url":"https://api.github.com/users/theodesp","html_url":"https://github.com/theodesp","followers_url":"https://api.github.com/users/theodesp/followers","following_url":"https://api.github.com/users/theodesp/following{/other_user}","gists_url":"https://api.github.com/users/theodesp/gists{/gist_id}","starred_url":"https://api.github.com/users/theodesp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theodesp/subscriptions","organizations_url":"https://api.github.com/users/theodesp/orgs","repos_url":"https://api.github.com/users/theodesp/repos","events_url":"https://api.github.com/users/theodesp/events{/privacy}","received_events_url":"https://api.github.com/users/theodesp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-09-10T11:34:18Z","updated_at":"2018-09-10T13:46:49Z","closed_at":null,"author_association":"NONE","body":"I'm trying to Create a Real World example backend using https://github.com/gothinkster/realworld and I noticed that the CORS middleware is missing. I recommend before we attempt to showcase the example to actually have one at hand.\r\n\r\nSee:\r\nhttps://github.com/ottoyiu/django-cors-headers\r\nhttps://github.com/corydolphin/flask-cors\r\nhttps://github.com/barryvdh/laravel-cors\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/MasoniteFramework/core/issues/comments/419917709","html_url":"https://github.com/MasoniteFramework/core/issues/320#issuecomment-419917709","issue_url":"https://api.github.com/repos/MasoniteFramework/core/issues/320","id":419917709,"node_id":"MDEyOklzc3VlQ29tbWVudDQxOTkxNzcwOQ==","user":{"login":"hammacktony","id":10157988,"node_id":"MDQ6VXNlcjEwMTU3OTg4","avatar_url":"https://avatars0.githubusercontent.com/u/10157988?v=4","gravatar_id":"","url":"https://api.github.com/users/hammacktony","html_url":"https://github.com/hammacktony","followers_url":"https://api.github.com/users/hammacktony/followers","following_url":"https://api.github.com/users/hammacktony/following{/other_user}","gists_url":"https://api.github.com/users/hammacktony/gists{/gist_id}","starred_url":"https://api.github.com/users/hammacktony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hammacktony/subscriptions","organizations_url":"https://api.github.com/users/hammacktony/orgs","repos_url":"https://api.github.com/users/hammacktony/repos","events_url":"https://api.github.com/users/hammacktony/events{/privacy}","received_events_url":"https://api.github.com/users/hammacktony/received_events","type":"User","site_admin":false},"created_at":"2018-09-10T13:46:49Z","updated_at":"2018-09-10T13:46:49Z","author_association":"CONTRIBUTOR","body":"So, something like this?\r\n\r\n```\r\n\"\"\" CORS Middleware \"\"\"\r\nfrom masonite.request import Request\r\n\r\nclass CORSMiddleware:\r\n\r\n    def __init__(self, request: Request):\r\n        self.request = request\r\n\r\n    def after(self):\r\n        if not self.request.header('Content-Type'):\r\n            if isinstance(self.request.app().make('Response'), dict):\r\n                cors = \"\"\r\n                request.header('CORS_ORIGIN_ALLOW_ALL', cors, http_prefix=None)\r\n            else:\r\n                self.request.header(\r\n                    'Content-Type', 'text/html; charset=utf-8', http_prefix=None)\r\n\r\n```"}}
{"actor":{"display_login":"hammacktony"}}