Categories
Mastering Development

Calling a function inside another funciot in React

I’m making a Login form which is working, what I want is make that pressing enter makes the same that clicking the submit button. Put here my code.Thanks. handleSubmit(e) { const TOKEN = ‘Bearer ‘ + getToken(); e.preventDefault(); const datapost = { username : this.state.username, password : this.state.password } let axiosConfig = { headers: { […]

Categories
Mastering Development

SAM app deploy gives preflight error but if I create OPTIONS method in aws apigateway console my preflight passes

I’m using SAM to create an API in cloudformation. QUESTION: Where in my SAM application template do I add the ‘X-Requested-With’ header? How can I edit my code so that the preflight will succeed without me having to go into the AWS console? PROBLEM: I’m working with my preflight request and when I deploy my […]

Categories
Mastering Development

Drupal 8 POST /user/login?_format=json 500 (500 Service unavailable (with message))

I am trying to get a simple user login to work using fetch POST in a ReactJS app against Drupal 8.8 Rest endpoint so I can POST with CSRF or other methods. If I issue the following with a CURL request: curl –header “Content-type: application/json” –request POST –data ‘{“name”:”myname”, “pass”:”mypassword123″}’ http://example.com/user/login?_format=json … I get … […]

Categories
Mastering Development

Browser says access-control-allow-origin header not present in clojure ring

I make a request to a server through the client browser like so https://example.com/bar, but get the error: Access to XMLHttpRequest at ‘https://example.com/bar/’ from origin ‘https://www.example.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. However, when using clj-http.client, I get the following headers: {“Access-Control-Allow-Headers” “Content-Type”, “Server” “Aleph/0.4.4”, “Via” […]

Categories
Mastering Development

Send a file to Telegram with Julia

I’m writing a Telegram bot in Julia and I can’t figure out how to send files correctly. I’ve seen similar questions for other languages but it wasn’t helpful. Currently, I have such function: function sendDoc(chat, fileName::String) file = open(fileName) url = string(base_url, “sendDocument”) mp = HTTP.Multipart(basename(fileName), file) query = Dict(“chat_id” => chat) HTTP.post(url; query=query, files=Dict(“document” […]

Categories
Development

Lambda CORS error blocked in client but works in Postman

I know that there have been many topics written on this subject, and, trust me, I’ve looked at all of them at this point. This is the exact error: Access to XMLHttpRequest at ‘https://8udb877nfi.execute-api.us-east-1.amazonaws.com/prod/bulk-updater’ from origin ‘http://localhost:3000’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header […]

Categories
Development

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource (POST request with object)

I enabled CORS in my web api application var cors = new EnableCorsAttribute(“*”, “*”, “*”); config.EnableCors(cors); All the requests are working fine. but when i pass an object to the post method i get this: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:44367/api/Users/Create. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). // […]

Categories
Development

Spring Security CORS issue when passing Authorization header

I had wasted lot’s of time fixing this issue, but none of the existing solutions work in my case. Let me explain you the server set up I have. I have 2 docker containers, one for angular app (nginx – url – http://localhost:8080) and spring boot application (tomcat – url – http://localhost:8081). This app is […]

Categories
Development

POST to API from React frontend is not working — Error 400

I’m trying to send data to my Flask API to get data into my database, but I keep getting the following error: OPTIONS /createUser HTTP/1.1″ 400 Reg.js import React, { Component } from ‘react’; class Reg extends Component { constructor() { super(); this.state = { FirstName: ”, LastName: ”, Email: ”, Password: ” } this.Email […]

Categories
Development

Connecting PHP Api on server with React expo app localhost. Base url fails

After hours of trying is still can’t get my React Expo application (localhost http://192.168.1.113:19006/#/) to connect to my PHP api that is hosted on an external server. The header of my api file’s is as following; header(“Access-Control-Allow-Origin: *”); //header(“Access-Control-Allow-Headers: *”); //header(“Access-Control-Allow-Credentials: ‘true'”); header(“Content-Type: application/json”); header(“Access-Control-Allow-Methods: POST”); header(“Access-Control-Max-Age: 3600”); header(“Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With”); When I […]