Fix api env variable usage
This commit is contained in:
@@ -7,12 +7,12 @@ const secure = jwt({
|
|||||||
cache: true,
|
cache: true,
|
||||||
rateLimit: true,
|
rateLimit: true,
|
||||||
jwksRequestsPerMinute: 5,
|
jwksRequestsPerMinute: 5,
|
||||||
jwksUri: `https://${process.env.SNOWPACK_PUBLIC_AUTH0_DOMAIN}/.well-known/jwks.json`,
|
jwksUri: `https://${process.env.auth0Domain}/.well-known/jwks.json`,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
// Validate the audience and the issuer
|
// Validate the audience and the issuer
|
||||||
audience: `https://${process.env.SNOWPACK_PUBLIC_API_DOMAIN}/`, //replace with your API's audience, available at Dashboard > APIs
|
audience: process.env.auth0Audience, //replace with your API's audience, available at Dashboard > APIs
|
||||||
issuer: `https://${process.env.SNOWPACK_PUBLIC_AUTH0_DOMAIN}/`,
|
issuer: `https://${process.env.auth0Domain}/`,
|
||||||
algorithms: ["RS256"],
|
algorithms: ["RS256"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,3 +16,5 @@ inputs:
|
|||||||
dbIndex1: ${output:database.indexes.gsi1.name}
|
dbIndex1: ${output:database.indexes.gsi1.name}
|
||||||
# A secret token to sign the JWT tokens with.
|
# A secret token to sign the JWT tokens with.
|
||||||
tokenSecret: ${env:tokenSecret} # Change to secret via environment variable: ${env:tokenSecret}
|
tokenSecret: ${env:tokenSecret} # Change to secret via environment variable: ${env:tokenSecret}
|
||||||
|
auth0Audience: "https://${env:SNOWPACK_PUBLIC_API_DOMAIN}/"
|
||||||
|
auth0Domain: ${env:SNOWPACK_PUBLIC_AUTH0_DOMAIN}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useAuth0 } from "@auth0/auth0-react";
|
import { useAuth0 } from "@auth0/auth0-react";
|
||||||
|
import config from "../config";
|
||||||
|
|
||||||
const ProfileFromApi = () => {
|
const ProfileFromApi = () => {
|
||||||
const { user, isAuthenticated, getAccessTokenSilently } = useAuth0();
|
const { user, isAuthenticated, getAccessTokenSilently } = useAuth0();
|
||||||
@@ -9,12 +10,11 @@ const ProfileFromApi = () => {
|
|||||||
const getMessage = async () => {
|
const getMessage = async () => {
|
||||||
try {
|
try {
|
||||||
const accessToken = await getAccessTokenSilently({
|
const accessToken = await getAccessTokenSilently({
|
||||||
audience: "https://1t8da6s66e.execute-api.us-east-1.amazonaws.com/",
|
audience: config.auth0.audience,
|
||||||
scope: "read:stuff",
|
scope: "read:stuff",
|
||||||
});
|
});
|
||||||
|
|
||||||
const authorizedUrl =
|
const authorizedUrl = `${config.domains.api}/test-authorized/`;
|
||||||
"https://1t8da6s66e.execute-api.us-east-1.amazonaws.com/authorized";
|
|
||||||
|
|
||||||
const authorizedResponse = await fetch(authorizedUrl, {
|
const authorizedResponse = await fetch(authorizedUrl, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user