Over a million developers have joined DZone.

I Like Working With JSON on GitHub Because CORS Is Never an Issue

Because of the way JSON is loaded, Cross Origin Resource Sharing can apply to seemingly inert JSON file resources on other servers.

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

I tend to only work in environments where I have full control over the server, so Cross-origin Resource Sharing (CORS) is never really an issue for any of the APIs I have control over, but it is a pervasive problem for APIs and with JSON files I come across on the web. This is one of the reasons I really enjoy the fact that I publish all of my JSON-driven, hacker-storytelling projects using GitHub Pages and Jekyll.

In the last couple weeks, I have been working on a bunch of micro tools that deliver specific functionality which can then be used throughout the API life cycle. All of these apps are developed using JavaScript and depend on being able to read from any number of JSON file stores. Sometimes these files are stored within the project, but most likely I'm calling the remote JSON files of other projects, something that depends on the sharing of resources across domains.

If I am publishing a JSON file publicly on the open Internet, I want it to be accessible from anywhere. CORS has to be default. The speed and agility at which I'm able to ingest and work with APIs, JSON files, and the OpenAPI Spec indexes they contain, sets me up for some serious nimbleness across my work.

If you are working with open data on the web, make sure and consider CORS enablement by default when working with your JSON data on GitHub. It will make your life easier, as well as anyone else who will be looking to consume the valuable data you are putting out there.

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.

Topics:
json ,github ,cors

Published at DZone with permission of Kin Lane, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}