Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust Environment Variables #61

Merged
merged 2 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NEXT_PUBLIC_API_KEY=
TINYURL_API_KEY=
5 changes: 4 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: false,
serverRuntimeConfig: {
API_KEY: process.env.TINYURL_API_KEY,
},
reactStrictMode: true,
swcMinify: true,
};
2 changes: 0 additions & 2 deletions src/constants/baseConfig.ts

This file was deleted.

5 changes: 4 additions & 1 deletion src/pages/api/shorten.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import axios from "axios";
import type { NextApiRequest, NextApiResponse } from "next";

import { BASE_URL, API_KEY } from "@/constants/baseConfig";
// We can no longer use the environment variables in `constants`, as the
// environment variables are now on the server, not the browser.
const API_KEY = process.env.TINYURL_API_KEY;
const BASE_URL = "https://api.tinyurl.com/";

type LinkFailureResponse = {
message: string;
Expand Down