Para usar la Rest API es necesario proveer de consumer_key y consumer_secret en la URL como parámetros. (Nunca pude pasarlo en la cabecera)
Ejemplo:
https://mywebsite.com/wp-json/wc/v3/products?consumer_key=XXXX&consumer_secret=XXXX| version: '3' | |
| services: | |
| traefik: | |
| restart: unless-stopped | |
| image: traefik:v2.0.2 | |
| ports: | |
| - "80:80" | |
| - "443:443" | |
| labels: | |
| - "traefik.http.services.traefik.loadbalancer.server.port=8080" |
| function DNI_CL({ run, string }){ | |
| if(run !== '' && (typeof run === "string" || typeof run === "number")){ | |
| function format(n){ | |
| if (typeof n === 'string') { | |
| // Remove '.' if exist | |
| n = (n.includes('.')) ? n.split('.').join('') : n; | |
| // Remove '-' if exist | |
| n = (n.includes('-')) ? n.split('-').join('') : n; |
| # Editors | |
| .vscode/ | |
| .idea/ | |
| # Vagrant | |
| .vagrant/ | |
| # Mac/OSX | |
| .DS_Store |
| [opcache] | |
| ; Determines if Zend OPCache is enabled | |
| opcache.enable=1 | |
| ; Determines if Zend OPCache is enabled for the CLI version of PHP | |
| ;opcache.enable_cli=1 | |
| ; The OPcache shared memory storage size. | |
| opcache.memory_consumption=512 |
| context_title: "$Context.title", | |
| com_instructure_post_message_token: "$com.instructure.PostMessageToken", | |
| com_instructure_assignment_lti_id: "$com.instructure.Assignment.lti.id", | |
| com_instructure_originality_report_id: "$com.instructure.OriginalityReport.id", | |
| com_instructure_submission_id: "$com.instructure.Submission.id", | |
| com_instructure_file_id: "$com.instructure.File.id", | |
| course_offering_sourced_id: "$CourseOffering.sourcedId", | |
| context_id: "$Context.id", | |
| context_sourced_id: "$Context.sourcedId", | |
| message_document_target: "$Message.documentTarget", |
| { | |
| "regiones": [ | |
| { | |
| "region": "Arica y Parinacota", | |
| "comunas": ["Arica", "Camarones", "Putre", "General Lagos"] | |
| }, | |
| { | |
| "region": "Tarapacá", | |
| "comunas": ["Iquique", "Alto Hospicio", "Pozo Almonte", "Camiña", "Colchane", "Huara", "Pica"] | |
| }, |
Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served. This is set on the server-side and there is nothing you can do from the client-side to change that setting, that is up to the server/API. There are some ways to get around it tho.
Sources : MDN - HTTP Access Control | Wiki - CORS
CORS is set server-side by supplying each request with additional headers which allow requests to be requested outside of the own domain, for example to your localhost. This is primarily set by the header:
Access-Control-Allow-Origin| // Add a 401 response interceptor | |
| window.axios.interceptors.response.use(function (response) { | |
| return response; | |
| }, function (error) { | |
| if (401 === error.response.status) { | |
| swal({ | |
| title: "Session Expired", | |
| text: "Your session has expired. Would you like to be redirected to the login page?", | |
| type: "warning", | |
| showCancelButton: true, |