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

Feature/web 9 agregar.env y run tunnel #4

Merged
merged 6 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Si se modifican variables en .env, es necesario ejecutar el comando "expo r -c" para reconstruir el cache
* de otro modo, el modulo react-native-dotenv utiliza los valores cacheados y no se ven reflejadas las actualizaciones
*/
API_BASE_URL="http://10.0.2.2:3000/api/v1"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ npm-debug.*
*.mobileprovision
*.orig.*
web-build/
.env

# macOS
.DS_Store
Expand Down
12 changes: 12 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = function (api) {
api.cache(true);
davslabs marked this conversation as resolved.
Show resolved Hide resolved
return {
presets: ['babel-preset-expo'],
plugins: [
[
'module:react-native-dotenv',
{ moduleName: '@env', path: '.env', blacklist: null, whitelist: null, safe: false, allowUndefined: true },
],
],
};
};
47 changes: 47 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"prepare": "husky install",
"start": "expo start",
"tunnel": "expo start --tunnel",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
Expand All @@ -19,12 +20,14 @@
"@react-navigation/native": "^6.0.13",
"@react-navigation/native-stack": "^6.9.1",
"axios": "^1.1.3",
"babel": "^6.23.0",
"expo": "~46.0.16",
"expo-secure-store": "^11.3.0",
"expo-status-bar": "~1.4.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-native": "0.69.6",
"react-native-dotenv": "^3.3.1",
"react-native-web": "~0.18.7"
},
"devDependencies": {
Expand Down
8 changes: 5 additions & 3 deletions src/api/axios.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import axios from 'axios';

const BASE_URL = 'http://10.0.2.2:3000/api/v1';
import { API_BASE_URL } from '@env';

export default axios.create({
baseURL: BASE_URL,
baseURL: `${API_BASE_URL}`,
});

console.log(`BASE URL == ${API_BASE_URL}`);

export const axiosPrivate = axios.create({
baseURL: BASE_URL,
baseURL: `${API_BASE_URL}`,
headers: { 'Content-Type': 'application/json' },
withCredentials: true,
});
3 changes: 3 additions & 0 deletions src/types/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module '@env' {
export const API_BASE_URL: string;
}
davslabs marked this conversation as resolved.
Show resolved Hide resolved