Skip to content

Commit

Permalink
Fixed stripe issue with cors, also removing unnecesaries comments and…
Browse files Browse the repository at this point in the history
… variables
  • Loading branch information
samilabud committed Mar 7, 2024
1 parent 8761788 commit 6e9bb0c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ yarn-error.log*
npm-debug.log*
yarn-debug.log*
yarn-error.log*

.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import StripeCheckout from 'react-stripe-checkout';
import axios from 'axios';

const StripeCheckoutButton = ({price}) => {
const backendURL = process.env.BACKEND_URL ? process.env.BACKEND_URL : '';
const backendURL = process.env.REACT_APP_BACKEND_URL ? process.env.REACT_APP_BACKEND_URL : '';
const priceForStripe = price * 100;
const publishablekey = 'pk_test_51IfAwgF7VDSpoZmOV8VtWIwE4hJOLce3ch0DPT5DkwR8Gm0g8DWhqqxGmI3qkSywYrnGEbdIbhaNNXpbTTpzWgGO00J2aOGAhi';
//const secretkey = 'sk_test_51IfAwgF7VDSpoZmO90Kbmy03DFqIOQxE6r6niC190Z79kp94GJIILU8bGTjlFlOIN9TD4LTxdaoFCeQ3HzkPLXiw00sifdGSKj';
const publishablekey = process.env.REACT_APP_STRIPE_PUBLISHABLE_KEY;
const onToken = () => {
axios({
url: `${backendURL}payment`,
Expand Down
1 change: 0 additions & 1 deletion client/src/redux/user/user.saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export function* getSnapshotFromUserAuth(userAuth, additionalData) {
userAuth,
additionalData
);
console.log({ userRef });
const userSnapshot = yield getDoc(userRef);
if (userSnapshot) {
yield put(SignInSuccess({ id: userSnapshot.id, ...userSnapshot.data() }));
Expand Down
2 changes: 1 addition & 1 deletion client/src/utils/stripe/stripe.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import { loadStripe } from "@stripe/stripe-js";
//const secretkey = 'sk_test_51IfAwgF7VDSpoZmO90Kbmy03DFqIOQxE6r6niC190Z79kp94GJIILU8bGTjlFlOIN9TD4LTxdaoFCeQ3HzkPLXiw00sifdGSKj';
export const stripePromise = loadStripe(
process.env.REACT_APP_STRIPE_PUBLISHABLE_KEY
);
);
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dependencies": {
"body-parser": "^1.18.3",
"compression": "^1.7.4",
"cors": "2.8.5",
"cors": "^2.8.5",
"dotenv": "^7.0.0",
"express": "^4.16.4",
"express-sslify": "^1.2.0",
Expand Down
12 changes: 4 additions & 8 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@ const express = require("express");
const path = require("path");
const compression = require("compression");
const enforce = require("express-sslify");
var cors = require("cors");

if (process.env.NODE_ENV !== "production") {
require("dotenv").config();
}

const stripe = require("stripe")(process.env.STRYPE_SECRET_KEY);

const app = express();
const port = process.env.PORT || 2500;

//Middelwares
app.use(express.urlencoded({ extended: false })); //parsear el request por post y html por form url encoded
app.use(express.json()); //parsear el request por json
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
if (process.env.NODE_ENV === "production") {
app.use(compression());
// app.use(enforce.HTTPS({trustProtoHeader:true}));
// app.use(express.static(path.join(__dirname, 'client/build')));
// app.get('*', function(req, res){
// res.sendFile(path.join(__dirname,'client/build','index.html'));
// })
}
app.use(cors());

app.listen(port, (error) => {
if (error) {
Expand Down

0 comments on commit 6e9bb0c

Please sign in to comment.