Skip to content

Commit

Permalink
Merge pull request #79 from casper-network/ip-detection
Browse files Browse the repository at this point in the history
ADDED: clientside ip detection for hubspot forms
  • Loading branch information
sd-ditoy authored Nov 14, 2023
2 parents 221dd31 + ed6c263 commit 3adc9d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docker/nginx-default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ server {
set $CSP_STYLE "style-src 'self' 'unsafe-inline'";
set $CSP_FONT "font-src 'self' https:";
set $CSP_SCRIPT "script-src 'self' 'unsafe-eval' 'unsafe-inline' https:";
set $CSP_CONNECT "connect-src 'self' blob: https:";
set $CSP_CONNECT "connect-src 'self' blob: https: https://api.ipify.org";
set $CSP_MEDIA "media-src 'self' blob: https:";
set $CSP_OBJECT "object-src 'none'";
set $CSP_WORKER "worker-src blob:";
Expand Down
7 changes: 6 additions & 1 deletion src/components/blocks/HubspotForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,12 @@ export default {
this.$v.$touch();
if (!this.$v.$invalid) {
const hubspotUtk = Cookie.get('hubspotutk');
const ipAddress = this.definition?.ip || null;
let ipAddress = null;
const res = await fetch('https://api.ipify.org/?format=json');
if (res.ok) {
ipAddress = (await res.json() || {}).ip || null;
}
const definition = this.computedFields;
const fields = [];
definition.forEach((def) => {
Expand Down

0 comments on commit 3adc9d8

Please sign in to comment.