Method PATCH is not allowed by Access-Control-Allow-Methods in preflight response

Boa noite Guy’s!

Estou enfrentando um problema quando tento fazer uma requisição do tipo PATCH para meu servidor escrito com o framework ExpressJS. As requisições usando GET, POST e DELETE funcionam normalmente. As requisições vem de uma aplicação escrita usando Angular.

Este é o erro que estou recebendo:

Access to XMLHttpRequest at 'http://localhost:3000/events/61' from origin 'http://localhost:4200' has been blocked by CORS policy: Method PATCH is not allowed by Access-Control-Allow-Methods in preflight response. 

Ja tentei configurar os Headers usando o seguinte codigo:

app.use(function(req, res, next) {   req.header('Access-Control-Allow-Origin', '*');   req.header('Access-Control-Allow-Methods', 'GET,POST,DELETE,OPTIONS,PATCH');   req.header('Access-Control-Allow-Headers', 'Content-Type');   next(); }); 

Ja tentei importando o modulo Cors:

const cors = require('cors');  

Nenhuma dessas tentativas resolveu meu problema. O que poderia ser?

Att. Jeiferson

Information leakage through json response

I am testing a product survey website. As a response to getSurveyResults() call, the following details of all survey participants shall be displayed to all website users.

  1. Nick name
  2. Location
  3. Rating
  5. Age

However, in results json, I could see the following additional fields for each survey participant.

  1. Order ID (product purchase ID)
  2. Survey questions and answers such as married or not, number of pets etc
  3. Incentive received to write review
  4. Locale

Though these are not PII, does this come under data leakage issue?

404 Response from NGINX when trying to setup mediawiki short urls

I have NGINX setup to serve content over localhost with HTTPS. Using the following location block, I can serve mediawiki just fine (it is in the /w folder)

location ~ /w/(.*)(\.php)?$   {   index index.php index.html;   try_files $  uri $  uri.php /w/index.php =404;   fastcgi_pass;   include fastcgi_params;   fastcgi_param SCRIPT_FILENAME $  document_root$  fastcgi_script_name;   fastcgi_param SCRIPT_NAME $  fastcgi_script_name; } 

However, when I try to setup short urls (https://localhost/wiki/Some_Page for example) using this guide, I always get 404 file not found. I’m using PHP-FPM as the upstream, for reference. Here is the full configuration I’m using with NGINX to achieve short URLs

worker_processes 1;  events {   worker_connections 1024; }  http {   include mime.types;   default_type application/octet-stream;   sendfile on;   keepalive_timeout 65;   gzip on;    log_format compression '$  time_local - "$  uri" $  status "$  http_referer" $  request_filename';   access_log /Users/nicholas.chambers/log/nginx/access.log compression;   error_log /Users/nicholas.chambers/log/nginx/error.log;    server {     listen 80;     server_name localhost;     return 301 https://$  host$  request_uri;   }    server {     listen 443 ssl http2;     server_name localhost;      ssl_certificate /Users/nicholas.chambers/nginx/ssl/cert.pem;     ssl_certificate_key /Users/nicholas.chambers/nginx/ssl/private.key;     ssl_session_timeout 1d;     ssl_session_cache shared:SSL:50m;     ssl_session_tickets off;      ssl_protocols TLSv1.2;     ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';     ssl_prefer_server_ciphers on;     ssl_trusted_certificate /Users/nicholas.chambers/ca/intermediate/certs/chain.pem;      root /Users/nicholas.chambers;      allow;     deny all;      location ~ /wordpress/(.*)(\.php)?$   {       index index.php index.html;       try_files $  uri $  uri.php /wordpress/$  1/index.php /wordpress/index.php =404;       fastcgi_pass;       include fastcgi_params;       fastcgi_param SCRIPT_FILENAME $  document_root$  fastcgi_script_name;       fastcgi_param SCRIPT_NAME $  fastcgi_script_name;     }      location ~ ^/w/(index|load|api|thumb|opensearch_desc)\.php$   {       include fastcgi_params;       fastcgi_param SCRIPT_FILENAME $  document_root/w/$  fastcgi_script_name;       fastcgi_pass; # or whatever port your PHP-FPM listens on     }      location /w/images {     }      location /w/images/deleted {       deny all;     }      location ~ ^/w/resources/(assets|lib|src) {       try_files $  uri 404;       add_header Cache-Control "public";       expires 7d;     }      location ~ ^/w/(skins|extensions)/.+\.(css|js|gif|jpg|jpeg|png|svg)$   {       try_files $  uri 404;       add_header Cache-Control "public";       expires 7d;     }      location = /favicon.ico {       alias /w/images/6/64/Favicon.ico;       add_header Cache-Control "public";       expires 7d;     }      location /wiki/ {       rewrite ^/wiki/(?<pagename>.*)$   /w/index.php;       include fastcgi_params;       fastcgi_param SCRIPT_FILENAME $  document_root/w/index.php;       fastcgi_param PATH_INFO $  pagename;       fastcgi_param QUERY_STRING $  query_string;       fastcgi_pass;     }      location = /robots.txt {     }   } } 

I haven’t made any changes to my LocalSettings.php, except for adding the following data

$  wgScriptPath = "/w"; $  wgScriptExtension = ".php"; $  wgArticlePath = "/wiki/$  1"; $  wgUsePathInfo = true; 

Thanks in advance!

How to convert multi-value answers into single column in Google Forms’ response sheet?

I have a Google form that asks for Name and up to 3 Score. The data is dumped into a sheet like this

enter image description here

But that data is not very convenient. I want to have the data like this…

enter image description here

Can I do that by adding a new sheet to the workbook, and some kind of LOOKUP formula? Or can I change the settings on the FORM to write up to 3 rows per submit?

Manipulate the response from Facebook API

Having this response from Facebook Graph API:

    "data": [         {          "name": "page_impressions",          "period": "day",          "values": [             {                "value": 0,                "end_time": "2019-04-16T07:00:00+0000"             },             {                "value": 0,                "end_time": "2019-04-17T07:00:00+0000"             }          ],          "title": "Daily Total Impressions",          "description": "Daily: The number of times any content from your Page or about your Page entered a person's screen. This includes posts, check-ins, ads, social information from people who interact with your Page and more. (Total Count)",         },     {       "name": "page_fan_adds",       "period": "day",       "values": [         {           "value": 0,           "end_time": "2019-04-16T07:00:00+0000"         },         {           "value": 0,           "end_time": "2019-04-17T07:00:00+0000"         }       ],       "title": "Daily New Likes",       "description": "Daily: The number of new people who have liked your Page (Total Count)",       "id": "145648302731807/insights/page_fan_adds/day",     }]} 

My code until now:

def manipulate(result):     dates = []     if "data" in result:         dates = result['data']      entriesToRemove = {'description', 'title', 'period', 'id'}     for element in dates:         for entries in entriesToRemove:             element.pop(entries, False)      return dates 

…which returns: [{'values': [{'end_time': '2019-04-14T07:00:00+0000', 'value': 0}, {'end_time': '2019-04-15T07:00:00+0000', 'value': 0}], 'name': 'page_impressions'}, {'values': [{'end_time': '2019-04-16T07:00:00+0000', 'value': 0}, {'end_time': '2019-04-17T07:00:00+0000', 'value': 0}], 'name': 'page_fan_adds'}]

… I would like to manipulate it to this final form:

[{     "page_impressions": 0,     "end_time": "2019-04-16T07:00:00+0000",     },   {     "page_impressions": 0,     "end_time": "2019-04-17T07:00:00+0000",     }, {     "page_fan_adds": 0,     "end_time": "2019-04-16T07:00:00+0000",     }, {     "page_fan_adds": 0,     "end_time": "2019-04-17T07:00:00+0000",     }, ] 

How should I approach this situation? I can’t figure it out about manipulating the response. Or maybe there is another way to do this…

Determining response codes from void functions OOP

I am trying to create a Put endpoint using rest. Let’s say that under the link


I am trying to add a new address (if that id doesn’t exist) or I’m trying to update it if it does already exist.

My application has several layers Controllers, Services, Models and Repositories. Given the fact that the business layer decides if an update or an add is required (this logic takes place in the service layer and below), how would the controllers be able to find out if an update or an add happened and return the correct status codes (201 for resource created, 204 if just an update has occured)?

My only ideas are to return some sort of result object, but that doesn’t feel particularly correct. For the cases where the service methods are not void, they usually return DTOs.

Facing difficulty in initialize i18next react component with fetch response data?

I am using i18next to do the internalization.

Default fetch request used to get a data from server and the language information available in response data. Based on language info the page has to be loaded with corresponding language

import i18n from 'i18next'; import { reactI18nextModule } from 'react-i18next'; import LanguageDetector from 'i18next-browser-languagedetector'; import translationEN from './locales/en/translation.json'; import translationDE from './locales/de/translation.json';  // the translations let language; function sendRequest(resources) {   console.log('resources', resources);   i18n     .use(reactI18nextModule) // passes i18n down to react-i18next     .init(       {         resources,         lng: language,         fallbackLng: 'en',         keySeparator: false, // we do not use keys in form messages.welcome          interpolation: {           escapeValue: false // react already safes from xss         }       },       function() {         fetch('http://localhost:3100/getLang')           .then(data => data.json())           .then(res => {             console.log(res);             language = res.lang;             i18n.changeLanguage(language, (err, t) => {               if (err)                 return console.log(                   'something went wrong loading the language',                   err                 );             });           });       }     );   return i18n; } function i18() {   const resources = {     en: {       translation: translationEN     },     de: {       translation: translationDE     }   };   return sendRequest(resources); } export default i18(); 

Language variable is undefined initially. For the very first time i18n init method setup with “fallbackLng” variable instead of “lng”. After that fetch request goes in callback of init method. That will have the response of language need to used. Then i18n changeLanguage method will help to change language.

I am just wondering how can i execute fetch request prior to i18n initialization. I don’t like the approach of initialize the i18next with some default language first and then moved to different language. When i tried to initialize i18n in then part of fetch request doesn’t works for me.

Is there any alternative way available to execute fetch request first and then setup i18n before exporting the component?

Thanks in advance for any suggestion!

SOAP output requests post giving string response (XML output) but not sure how to read the same

response =,data=body,headers = headers) print(response.text) or print(response.content) it is printing Reponse—- b’——=_Part_1259_1689825246.1555312654314\r\nContent-Type: application/xop+xml;charset=UTF-8;type=”text/xml”\r\nContent-Transfer-Encoding: 8bit\r\nContent-ID: <1bd8e87f-9242-43b8-9593-e5a322e0eff5>\r\n\r\n\n1CHECKIN_UNIVERSALFAFusionImportExport \r\n——=_Part_1259_1689825246.1555312654314–\r\n’

From above string i want to read “dSecurityGroup” value i.e “FAFusionImportExport” and i am not sure how to read this data. could you please help me on this.

How to make discussion board management view link to response thread?

From subject view:

enter image description here

If I click the title hyperlink it takes me to the response thread here:

enter image description here

But I created a new view based off the management view, and I want it to be simple to click the item and have it take you to the response thread.

Right now it looks like this:

enter image description here

But if you click those titles it takes you to a list view of the responses, not the reply thread. To get to the reply thread you need to right-click, click view item, then in the dialog that opens, click open.

Under the settings for Modify View, there are the column options:

  • Subject (linked to item with edit menu)
  • Subject (linked to item with edit menu) (old)
  • Subject (linked to item)
  • Type (icon linked to document)

But unfortunately none of them link where I want to go.

Is there a way to streamline this to link directly to the response thread?