Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

288
Visualizações
How do I set the origin in the DeepL API on javascript?

What else should I try?

I'm currently sending a request to the DeepL API in axios, but I'm getting a 403 response due to a CORS issue.

And tried to set the option using querystring as shown here, but it didn't work. https://github.com/funkyremi/deepl/blob/master/index.ts Also, using the library at the URL above returns 403.

Furthermore, there is no origin setting in the account settings of DeepL.

I tried using 'Content-Type': 'application/x-www-form-urlencoded' for axios headers: {}, and I also tried setting options for params: { } and not using querystring, but they didn't work.

import axios from 'axios'
import querystring from 'querystring';

export const translateDeepL = async() => {
  const options = {
      "auth_key": process.env.DEEPL_AUTH_KEY,
      "text": 'everyday is birthday.',
      "target_lang": 'JA',
  };
  const url = "https://api-free.deepl.com/v2/translate";
  const data = await axios.post(url, querystring.stringify(options)).then(r => r);
  console.log(data);
}
VM3451:1 POST https://api-free.deepl.com/v2/translate 403

the request use https with ngrok did't work also.

I also tried the GET method for "https://api-free.deepl.com/v2/usage" but got the same result.

It is definitely api-free.deepl.com since I am using the free plan.

By the way, the above code is executed as a component in React.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You might be being blocked because of sending a request from http (your localhost) to https, try using the proxy axios config, like

const response = await axios
.get("https://api-free.deepl.com/v2/translate", {
  params: {
    auth_key: x,
    text: y,
    target_lang: z
  },
  proxy: {
    host: "localhost",
    port: 8080
  }
});

return response; };

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda