Fix proper usage of the Allow-Origin header. Also send the
Allow-Credentials header and allow any requested headers.
Use the word "method" instead of "type". Improved the error message.
Fix accidental string to array conversion and undefined variable error
Fixed improper usage of the Allow-Origin header. Only one origin is allowed.
Simplified setting the Allow-Headers header