Using ZipCodeAPI with Subdomains

Troubleshooting ZipCodeAPI

CORS Issues with Subdomains

People often ask about using ZipCodeAPI with Subdomains. It works and you can test it before purchasing. Here are some things to check if you run into any issues.

If you are seeing CORS (Cross-Origin Resource Sharing) issues in your browser,
see https://www.zipcodeapi.com/zipblog/docs/2016/04/14/zipcode-testing-locally-and-resolving-cors-issues.html.
– You should specify your main domain example.com and any subdomain on the client setup.
– When making AJAX calls in Javascript, make sure to use the client key (starts with js-).

Issues Accessing the API through PHP

Check your settings, in particular the allow_url_fopen setting in your web host’s php.ini file. Make sure it is set to allow the file_get_contents function to work. It’s a boolean, so it is easy fix. Also, some hosting provides claim changes to this file are instantaneous, but it might really take 5-10 minutes.

Other Issues Accessing the API

Remember to test the calling URL directly in browser before thinking it’s the service that doesn’t work. However, note that using the Javascript client key directly in the browser instead of AJAX will result in an error.